Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Answer: How to check similarity of two hash tables

by RMGir (Prior)
on Apr 09, 2002 at 14:21 UTC ( #157730=categorized answer: print w/replies, xml ) Need Help??

Q&A > hashes > How to check similarity of two hash tables - Answer contributed by RMGir

Of course, the obligatory one-liner (ok, one-expression) version:
my $areEqual = (keys %hash1 == keys %hash2) && 0 == grep {!exists $hash2{$_}} keys %hash1;

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2018-08-17 23:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (184 votes). Check out past polls.

    Notices?