Re: "$#{$array} "



On Jul 29, Vineet Pande said:

I don't not understand how the $#{$array_r} returns "highest" element as 4 and not 5???

$#arrayname returns the highest INDEX in the array -- that means it returns the location of the last element in the array. If your array has 10 elements, $#array returns 9, because $array[9] is the 10th element.


There is no variable that is magically the highest value in an array.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart
.