Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2017-09-25 22:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (291 votes). Check out past polls.

    Notices?