Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
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.


in reply to difference between for and foreach?

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:

case KEY_for: case KEY_foreach:
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. ;)

  • Comment on Re: difference between for and foreach? (..the stench and the peril)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://53228]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.