Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: foreach only for a section of a list

by kennethk (Abbot)
on May 04, 2012 at 15:01 UTC ( [id://968934]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    for (my $i = 0; $i < @somewords -1; $i++) {
      print " $somewords[$i];\n"
    }
    
  2. or download this
    foreach $core (@somewords[0 .. $#somewords-1]) {
      print " ${core};\n"
    }
    
  3. or download this
    my $i = 0;
    foreach my $core (@somewords) {
      next if ++$i == @somewords;
      print " ${core};\n"
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-24 04:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found