Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Foreach Loops

by NetWallah (Abbot)
on Mar 17, 2005 at 00:42 UTC ( #440214=note: print w/ replies, xml ) Need Help??


in reply to Foreach Loops

I'm surprised no one has suggested using map for this purpose. That way, it is easy to track the previous element ..

my $prev; map { print qq($prev,$_ \n); $prev=$_} qw(uno dos tres); ##Output ,uno uno,dos dos,tres
Update: I just noticed that holli's solution above is functionally identical.

    ..."I don't know what the facts are but somebody's certainly going to sit down with him and find out what he knows that they may not know, and make sure he knows what they know that he may not know, and that's a good thing. I think it's a very constructive exchange," --Donald Rumsfeld


Comment on Re: Foreach Loops
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-07-31 10:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls