Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: foreach loops

by pbeckingham (Parson)
on Oct 08, 2006 at 13:19 UTC ( #576991=note: print w/ replies, xml ) Need Help??


in reply to foreach loops

I think a C-style for loop would be appropriate here:

my @names = ('rita', 'sue','bob', 'daisy'); for (my $i = 0; $i < @names; ++$i) { print $names[$i], ' ', ($names[$i+1] || ''), "\n"; }
Output:
rita sue sue bob bob daisy daisy



pbeckingham - typist, perishable vertebrate.


Comment on Re: foreach loops
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2015-01-29 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My top resolution in 2015 is:

















    Results (231 votes), past polls