in reply to Re^2: For loop trouble
in thread For loop trouble

It's for (EXPR1; EXPR2; EXPR3) {...}. Note that there are semi-colons between the expressions, not commas.

The first expression is run before entering the loop. Before each iteration the second expression is run; if false, the loop terminates. After each iteration, the third expression is run. For further details, see man perlsyn.

Replies are listed 'Best First'.
Re^4: For loop trouble
by afoken (Chancellor) on Jun 13, 2009 at 17:14 UTC
    Note that there are semi-colons between the expressions, not commas.

    In this case, the OP has constructed a foreach loop iterating $_ over a list of three elements: $i=500, $i=900 , $i += 100, which evaluates to 500, 900, 1000 and $i set to 1000 for ALL iterations of the loop.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^4: For loop trouble
by cheech (Beadle) on Jun 13, 2009 at 18:03 UTC
    Ugh the carelessness.. Thank you, I just needed to realize semi colons were to be used.