Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Mysterious for behavior

by Belgarion (Chaplain)
on Apr 21, 2004 at 19:11 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 20:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found