Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Difference between for and foreachby Hercynium (Hermit) |
on Sep 17, 2007 at 15:42 UTC ( [id://639435]=note: print w/replies, xml ) | Need Help?? |
I'm pretty certain that Joost is correct at least as far as the specifications of how each construct is supposed to work. I'd like to add that it's worth paying attention to the aliasing behavior in certain situations, where the loop iterator variable ($thing in this example) for my $thing (@things) { # do stuff to $thing # } is not a copy of the current element of @things but more like a reference (a magic one that does not need to be de-referenced). The side effects have bitten me in the past, before I learned better :) Also, I've just been reading Perl Best Practices by TheDamian and chapter 6 (around pg. 100) goes in-depth on some of the techincal *and* psychological implications of different ways of using for and it's brethren.
In Section
Seekers of Perl Wisdom
|
|