Hi,

I've just started using hash tables and could use some help with something. I need to whip through two hash tables and provide the following kind of summary:

1) elements common between two tables
2) elements unique to table #1
3) elements unique to table #2

Is there any way to do this with one pass through both hash tables, or do I pretty much have to pass through each hash table once?

Here's what I'm doing:-
%astpd = (); %astslack = (); $ln = 0; while ($in1s[$ln] ne "") { chop ($in1s[$ln]); @in1saa = split(/\s+/,$in1s[$ln]); $aststartend = join (" ",$in1saa[0],$in1saa[1]); $astpd{$aststartend} = $in1saa[2]; $astslack{$aststartend} = $in1saa[3]; undef (@in1saa); $ln++; } %ptpd = (); %ptslack = (); $ln = 0; while ($in2s[$ln] ne "") { chop ($in2s[$ln]); @in2saa = split(/\s+/,$in2s[$ln]); $ptstartend = join (" ",$in2saa[0],$in2saa[1]); $ptpd{$ptstartend} = $in2saa[2]; $ptslack{$ptstartend} = $in2saa[3]; undef (@in2saa); $ln++; }
Any suggestions on the *fastest* way to meet my 3 criteria above? (The keys to match are $aststartend and $ptstartend. Once a match is made, write $astpd, $ptpd, $astslack, and $ptslack to a file...)

Many thanks in advance...

update (broquaint): added <code> tags


In reply to Hash table question by fiddler42

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.