P is for Practical | |
PerlMonks |
Re: Mysterious for behaviorby Belgarion (Chaplain) |
on Apr 21, 2004 at 19:11 UTC ( [id://347100]=note: print w/replies, xml ) | Need Help?? |
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: 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.
In Section
Seekers of Perl Wisdom
|
|