print final element of an array reference using perl?
.Method 1:
@array=(1,33,11,4,5);
$r=\@array;
print "@$arr_ref [-1]";
Method 2:
@array=(1,33,11,4,5);
$r=\@array;
print $arr_ref->[-1];
Method 3:
@array=(1,33,11,4,5);
$r=\@array;
print @$r[$t-1]=$t=scalar(@$r);
Method 4:
@array=(1,33,11,4,5);
$r=\@array;
print splice(@$r,scalar(@$r-1),1);
Method 5:
@array=(1,33,11,4,5);
$r=\@array;
print @$r[($#=@$r-1)];
Method 6:
@array=(1,33,11,4,5);
$r=\@array;
print @$r[scalar(@$r-1)];
Method 7:
@array=(1,33,11,4,5);
$r=\@array;
print splice(@$r,-1,scalar(@$r-1));
For More Methods Reach Me:@ letscrackperlinterviewblogspot@gmail.com
0 Comments:
Post a Comment
Note: only a member of this blog may post a comment.
<< Home