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

RE: diff of two hashes.

by turnstep (Parson)
on May 12, 2000 at 19:16 UTC ( #11289=note: print w/replies, xml ) Need Help??

in reply to diff of two hashes.

Hrmmm...are the keys all the same, and do you need to know which hash the differences came from? A quick solution that pops to mind is:
for $x (keys %one) { delete $one{$x} if $two{$x} eq $one{$x}; } ## Show non-matching keys: for $x (keys %one) { print "$x ($one{$x})\n"; }

It destroys the hash, and does not check for keys that are in two but not one. For that, perhaps something like this:

for $x (keys %one) { print "DIFF: $x\n" if $one{$x} ne $two{$x}; } for $x (keys %two) { print "DIFF2: $x\n" unless $one{$x}; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11289]
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: (2)
As of 2020-08-09 23:19 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (55 votes). Check out past polls.