You've got several smaller chores that add up to the solution to your problem. Tackling the small chores will help you to solve the bigger picture.

In %out_hash, 'jibber jabber' holds those id's that are found in both 'jibber' and in 'jabber'. This is an intersection.

You also want %out_hash to keep the id's from "jibber" that are unique to "jibber" within the key named "jibber", and the same for "jabber". This is the symmetric difference.

You may get a start by looking at List::Compare, and by reading perlfaq4 under the section called "How do I compute the difference of two arrays? How do I compute the intersection of two arrays?" For your purposes, your input hashes are simply sparse arrays. Treat them as lists of id's indexed by hash keys instead of array indices, and you'll find your way around the problem. This response assumes you already know your way around Perl's references and complex datastructures. If you need help tackling those too just let us know where you need clarification.


Dave


In reply to Re: combining hashes based on key values by davido
in thread combining hashes based on key values by punkish

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.