P is for Practical | |
PerlMonks |
Re: Assigning the Length of an Array to a Variable (INDEX)by Anonymous Monk |
on Aug 25, 2013 at 23:46 UTC ( [id://1050879]=note: print w/replies, xml ) | Need Help?? |
I am trying to define a variable which has a value equal to the length of an array Easy enough, array in scalar context returns the size of the array (number of elements, the "length") The part that is giving me trouble, I want the length to vary as I read through the array one element at a time. WHAT? Unless you add/remove elements from the array, the size cannot change You 're not looking for the size/length of an array YOu 're not looking for the last index of the array You appear to be looking for the current index of an array, in which case you have to use a c-style for-loop, or if your perl is new enough, each array
In Section
Seekers of Perl Wisdom
|
|