G'day NewLondonPerl1,

You don't need to iterate through each hash, you only need to iterate through one of them because if the key doesn't exist in one then the condition of the key existing in all three is not met. If they vary substantially in size, pick the one with the least number of keys. The guts of your code will look something like:

for (keys %hash1) { if (exists $hash2{$_} and exists $hash3{$_}) { print $hash1{$_}, $hash2{$_}, $hash3{$_}; } }

You don't need to sort for the functionality to work. I'll leave you to format the output.

-- Ken


In reply to Re: Comparing keys in 3 different hashes and if they are the same them print the values on one line by kcott
in thread Comparing keys in 3 different hashes and if they are the same them print the values on one line by NewLondonPerl1

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.