Tom Allison wrote: > Vineet Pande wrote: >> I don't not understand how the $#{$array_r} returns "highest" element >> as 4 and not 5??? >> >> #!/usr/bin/perl >> use warnings; >> use strict; >> my @array = (1,2,3,4,5); >> my $array_r = [EMAIL PROTECTED]; >> print "the highest element is number $#{$array_r}\n"; > > You can also write this as $#$array_r if you are into perl golf. > > if you want the last value: > $$array_r[$#$array+1] or $array_r->[$#$array+1]
$#$array? Perhaps you meant $#$array_r? $array_r->[$#$array_r+1] is one past the end of the array which doesn't exist, perhaps you meant $array_r->[$#$array_r]? > ( but never use $#$array_r++ !!! ) > > To get the true length: $#$array + 1 Or better: scalar @$array_r John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>