Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: foreach loops

by Hofmator (Curate)
on May 27, 2002 at 14:02 UTC ( [id://169581]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Initialise an array so that $array[n] = n
    my $n = 0;
    foreach (@array) {$_ = $n++}
    
  2. or download this
    @array[0..100] = 0..100;
    
    # or to mimic the behaviour of your code exactly
    @array[0..$#array] = 0..$#array;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-18 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found