Perl-Sensitive Sunglasses | |
PerlMonks |
Re^4: array looping with foreachby mrpeabody (Friar) |
on Jan 19, 2008 at 04:10 UTC ( [id://663193]=note: print w/replies, xml ) | Need Help?? |
I thought that was the point! We try to be Perlish because this isn't language X. Perhaps our definitions of "Perlish" differ. There really is no truly Perlish idiom for this situation. The idiom in OP's second example has some benefits: it's simple, doesn't require any extra modules, is hard to screw up, and lets you safely insert or delete from your array. But -- playing language designer for a moment -- could it be better?
Hmm, too much repetition. Perhaps:
The array element and the index are implicitly localized to the loop, and the index is optional. If you want to iterate n-at-a-time you can do:
In Section
Seekers of Perl Wisdom
|
|