Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: for loops

by Willman023 (Scribe)
on Nov 07, 2002 at 16:30 UTC ( [id://211102]=note: print w/replies, xml ) Need Help??


in reply to for loops

I think it would be useful to show an additional way the for loop can be used. Although the C-like for loop can do the same thing, I find myself using the one below more and more.

for $countdown (10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 'Liftoff!') { print $countdown, "\n"; } for $y (0..$x) { print $array[$y], "\n"; } for (@array) { s/value1/value2/ } # Substitues value2 for value 1.

bW

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://211102]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-20 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found