http://www.perlmonks.org?node_id=44636


in reply to How do I find the size of an array?

Yes, it will return the last index, but the counting starts at 0 so this might confuse some people if the information is public. If you wanted to use  $#array and not confuse the user than add one to it..

$var = $#array + 1; or something of that sort.

Also, if you want to get the value of the last element in the array you can just use $array[-1].

Originally posted as a Categorized Answer.