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


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. ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://53228]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-28 23:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found