Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: comparing key-value pairs of two hashes

by Codon (Friar)
on Jul 22, 2005 at 12:21 UTC ( [id://477278]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: comparing key-value pairs of two hashes
in thread comparing key-value pairs of two hashes

For those working on their golf (or who just like some of the fun things that Perl can do), here's your exact code in 3 (Perl) lines.
my (@only_in_foo, @kv_different, @kv_equal); push( @{ exists $bar{$_} ? $bar{$_} eq $foo{$_} ? \@kv_equal : \@kv_different : \@only_in_foo}, $_) for keys %foo; my @only_in_bar = grep { ! exists $foo{$_} } keys %bar;
Ivan Heffner
Sr. Software Engineer, DAS Lead
WhitePages.com, Inc.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://477278]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.