|
|
| 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 16:09 UTC ( [id://53228]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
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
|
|
||||||||||||||||||||||||