Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Swapping names of list while keeping the contents as it is.

by philiprbrenan (Monk)
on Aug 30, 2012 at 18:32 UTC ( #990818=note: print w/ replies, xml ) Need Help??


in reply to Swapping names of list while keeping the contents as it is.

Try:

use feature ":5.14"; use warnings FATAL => qw(all); use strict; for(split /\n/, << 'END') jay 21 34 56 bob 12 39 jay 11 10 bob 14 jay 190 bob 13 END {s/jay/bob/ or s/bob/jay/; say }

Produces

bob 21 34 56
jay 12 39
bob 11 10
jay 14
bob 190
jay 13


Comment on Re: Swapping names of list while keeping the contents as it is.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (16)
As of 2014-10-23 11:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls