Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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) }


Comment on Re: for, foreach and $_...
Select or Download Code

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 imbibing at the Monastery: (10)
As of 2015-07-06 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (71 votes), past polls