Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: For vs. Foreach

by moritz (Cardinal)
on Feb 13, 2009 at 17:48 UTC ( [id://743653]=note: print w/replies, xml ) Need Help??


in reply to For vs. Foreach

They are synonyms, and you can find that out with B::Deparse:
$ perl -MO=Deparse -e 'foreach (1..2) { }' foreach $_ (1 .. 2) { (); } -e syntax OK $ perl -MO=Deparse -e 'for (1..2) { }' foreach $_ (1 .. 2) { (); } -e syntax OK

So they produce the same optree

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-24 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found