in reply to Last oddity

The last should end the for loop, as an EXPR1 while EXPR2 doesn't create a block for EXPR1, and last exits a block.

The difference between your two statements is that in the first one, you actually reach the last. But m/2/ && $i++ is never true. m/2/ is true only once, but then $i is still 0. Just add a 12 to your data file and notice the difference. In the expression $i++ && m/2/, $i is incremented each time, not only when there's a 2 in the input, making all the difference in the world.

Replies are listed 'Best First'.
Re^2: Last oddity
by Hena (Friar) on Oct 21, 2004 at 11:57 UTC
    Ups, should've been doing ++$i :D. Thanks for pointing out.