Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: key-values swapped

by thinker (Parson)
on Feb 18, 2005 at 09:44 UTC ( #432235=note: print w/ replies, xml ) Need Help??


in reply to key-values swapped

You could do

%test = reverse @hash;

but you would have to look out for collisions with the keys, which could cause you to lose values

cheers

thinker

Comment on Re: key-values swapped
Download Code
Replies are listed 'Best First'.
Re^2: key-values swapped
by Anonymous Monk on Feb 18, 2005 at 10:02 UTC
    Hi thinker,
    Your solution is good. Thank you.
    Regards,
Re^2: key-values swapped
by Tanktalus (Canon) on Feb 18, 2005 at 15:43 UTC

    Talking about hurting one's head ...

    Reversing a hash, you have to watch out for value collisions which could cause you to lose keys. At least, from the perspective of the original hash. Just trying to think about both hashes at the same time in the context of keys and values is giving me a headache. Where is my caffeine?

    Update for the humour-impaired: This is a joke. Relax. ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2016-04-29 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW







    Results (438 votes). Check out past polls.