Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Mysterious for behavior

by Belgarion (Chaplain)
on Apr 21, 2004 at 19:11 UTC ( #347100=note: print w/replies, xml ) Need Help??


in reply to Mysterious for behavior

The comma operator in this case is presenting a list of three elements to the initializer of the for operator. If you had something like this:

for ($i=3, $i=2, $i=1, $i=0)
you would get four lines, because there are four elements.

It is printing "1" for each input because the initializer list is evaulated before the iteration. Therefore, $i is set to one before the for operator iterates over the three element list.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2022-05-28 02:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (98 votes). Check out past polls.

    Notices?