I have two different hashes. One has three values per key (triplet), the other has two values per key (doublet). Both hashes are comprised of similar entries, e.g. where @A1 and @A2 may have duplicate matches in them.
I am trying to compare both hashes to find key-value-value pairings in the doublet that do not appear in the triplet. I have something like this so far, which checks for the presence of keys in the hash. However, I am not sure how to scale this up to check for all three values in %doublet in the %triplet and then print out any rows that are missing.
I hope that someone can advise!
my %triplet = map {($A1[$_] => [$B1[$_], $C1[$_], $D1[$_]]) } 0..$#tri +plet; my %doublet = map {($A2[$_] => [$D2[$_], $C2[$_]])}0..$#doublet; for (my $i=0; $i<@A2; $i++) { if (exists($triplet{$A2[$i]})) { print "$A2[$i]\n"; } else { } }
In reply to comparing values in two hashes by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |