in reply to Common hash keys
For the sake of esoteric aesthetics...
-InjunJoel#!/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";
"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
|
---|
In Section
Seekers of Perl Wisdom