Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: foreach loops

by Hofmator (Curate)
on May 27, 2002 at 14:02 UTC ( #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? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2022-05-24 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?