Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990818]
help
Chatterbox?
[ww]: Hola, stevieb -- looks lonely around here.
[ww]: Ah, not so much now.
[Your Mother]: Shhhhh, everyone ignore, ww.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2017-03-30 02:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (353 votes). Check out past polls.