in reply to Re: how internally $#array is working in Perl
in thread how internally $#array is working in Perl

$#array is the index of the last element in the array. Perl obviously knows how many elements there are in an array - if it didn't, then it wouldn't be able to automagically grow the array as you add more stuff to it and you'd have to handle memory allocation yourself. And perl obviously knows the index of the first element, which is the value in $[. Knowing how big the array is and the starting index, calculating the last index is trivial.