Perl: the Markov chain saw | |
PerlMonks |
Re: difference between for and foreach? (..the stench and the peril)by turnstep (Parson) |
on Jan 20, 2001 at 21:09 UTC ( [id://53228]=note: print w/replies, xml ) | Need Help?? |
Argh! There is no difference between "for" and "foreach." I write a lot of perl, and have never used "foreach". Why? Because "for" is less typing :). It's sheerly a stylistic thing. Here's the proof, direct from the perl source code: If you grok C, you'll realize that "for" falls through to the next case statement, the "foreach". Hence, no difference, except for the extra typing. Think of all the wear and tear saved on your keyboard over the years. ;)
In Section
Seekers of Perl Wisdom
|
|