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

Re: diff of two hashes.

by snowcrash (Friar)
on May 12, 2000 at 23:14 UTC ( #11348=note: print w/replies, xml ) Need Help??


in reply to diff of two hashes.

i would do something like this, where %a and %b are the hashes to compare:
foreach (sort keys %{{%a, %b}}) { if (!exists($b{$_})) { print "$_ only in a\n" } elsif (!exists($a{$_})) { print "$_ only in b\n" } elsif ($a{$_} ne $b{$_}) { print "$_: values in a and b differ\n" + } }
sc

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2019-07-22 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (12 votes). Check out past polls.

    Notices?