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) }


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 about the Monastery: (6)
As of 2014-08-01 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls