I have two hashes of key-value pairs of numbers. I want to find out how many of these key-value pairs are the same and different in both hashes (matching in both orientations e.g. key-key and key-value etc).
I have some code sort of working but it only works out which keys are different (below). Can someone help me to extend my code to find out which key-value pairs are the same and where the differences are?
Kind regards.
my %old_gp = map {$gp1_a[$_] => $gp1_b[$_]} 0 .. $#gp1_a; my %new_gp = map {$gp2_a[$_] => $gp2_b[$_]} 0 .. $#gp2_a; + + my @diff=(); foreach (keys %new_gp) { push (@diff, "$_ ") unless exists $old_gp{$_}; } + print @diff;
In reply to comparing key-value pairs of two hashes by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |