Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: for, foreach and $_...

by larsen (Parson)
on Aug 18, 2003 at 14:09 UTC ( #284580=note: print w/ replies, xml ) Need Help??


in reply to for, foreach and $_...

foreach(@array) { # $_ is an alias, in turn, for $array[ 0 ], $array[ 1 ], ... $array[ + n ] }
If you need a counter, try this:
foreach ( 0 .. $#array ) { # $_ 's value will be 0, 1, ..., (last index of @array) }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2016-06-30 11:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (393 votes). Check out past polls.