Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: For vs. Foreach

by moritz (Cardinal)
on Feb 13, 2009 at 17:48 UTC ( #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
Node Status?
node history
Node Type: note [id://743653]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2021-01-18 01:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?