Hi Monks,

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.