Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: for loop syntax difference

by Taulmarill (Deacon)
on Aug 28, 2009 at 14:02 UTC ( #791909=note: print w/replies, xml ) Need Help??

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 (Pope) 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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://791909]
[cbeckley]: I have a functioning module I use to spawn sets of commands across multiple servers.
[cbeckley]: It's nascent, and probably looks like baby Perl to the veterans.
[cbeckley]: I have several questions about it's future development. But it seems like a lot of code to put in a sopw.
[cbeckley]: Should I put the module and example calling code in cufp, and then ask questions in sopw?

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2017-03-24 15:00 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (304 votes). Check out past polls.