in reply to Re: How do I find the index of the last element in an array?
in thread How do I find the index of the last element in an array?
Hmm....actually, that doesn't really help at all!
If you want to know the index of the last element of an array, do this:
You can also refer to the value of the last element of the array
using negative indices, e.g. $letterList[-1] will also refer to "d".
--
Microsoft delendum est.
If you want to know the index of the last element of an array, do this:
This will, of course, output "3".@letterList = ("a", "b", "c", "d"); #refer to the last array index #using '$#array' syntax: print $#letterList;
You can also refer to the value of the last element of the array
using negative indices, e.g. $letterList[-1] will also refer to "d".
--
Microsoft delendum est.
|
---|
In Section
Seekers of Perl Wisdom