No such thing as a small change | |
PerlMonks |
Re: Index of Items in Array using foreach loopby tobyink (Canon) |
on Feb 22, 2013 at 10:50 UTC ( [id://1020131]=note: print w/replies, xml ) | Need Help?? |
Don't loop through the array; loop through the indices!
Or just use a sufficiently modern version of Perl...
Update: Although each @array was only added to Perl as of 5.12, Array::Each::Override provides a working implementation of each @array for Perl going back to 5.8.
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|