http://www.perlmonks.org?node_id=791909


in reply to for loop syntax difference

for $i (1..10) creates a list with ten elements and iterates of that.
for($i=0;$i<10;$i++) initializes $i with the value 0, then for every iteration of the loop it checks $i and increments if the check returns true or ends the loop.

Replies are listed 'Best First'.
Re^2: for loop syntax difference
by ikegami (Patriarch) on Aug 28, 2009 at 14:05 UTC

    for $i (1..10) creates a list with ten elements and iterates of that.

    No, it doesn't. It's optimised into a counting loop. It increments the loop counter every pass rather than creating a list.