Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Common hash keys

by injunjoel (Priest)
on Jun 08, 2008 at 20:46 UTC ( #690954=note: print w/ replies, xml ) Need Help??


in reply to Common hash keys

For the sake of esoteric aesthetics...

#!/usr/bin/perl -w use strict; my %a = ('a' =>1, 'b'=>2, 'c'=>5, 'd'=>19); my %b = ('b'=>12, 'd'=>32, 'z'=>77, 'y'=>5); my @common_keys = do{ local %_; $_{$_}++ for(keys %a, keys %b); delete @_{(map{ ($_{$_} == 1) ? $_ : ()}keys %_)}; sort keys %_; }; print "@common_keys";
-InjunJoel
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo


Comment on Re: Common hash keys
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-07-30 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls