References to good books or urls covering this issue will be appreciated.

I am new to Perl and confused a bit by hash of hashes, array of hashes:

Given the following %HOH:

# the key field is an arbitrary int that needs to be unique - it serves no purpose other than to provide a unique key for the hash

%HOH = [ { key => 1, person => "Mike", possession => "wallet, keys, car, house", age => 25, }, { key => 2, person => "Mike", possession => "dog, cat, baseball bat", age => 25, }, { key => 3, person => "Dave", possession => "pony, house, car, keys", age => 21, }, ];

How would one consolidate the hash of hashes to another hash of hashes or array of hashes so that if person and age were same, the possession would be a merge of the possession ... resulting in one entry per person/age combination but with all possessions in the array(list) of values for the possession key?

The desired result is:
%HOH = [ { key => 1, person => "Mike", possession => "wallet, keys, car, house, dog, cat, baseball bat" +, age => 25, }, { key => 3, person => "Dave", possession => "pony, house, car, keys", age => 21, }, ];
or
@AOH = ( { person => "Mike", possession => "wallet, keys, car, house, dog, cat, baseball bat" +, age => 25, }, { person => "Dave", possession => "pony, house, car, keys", age => 21, }, );

In reply to Confused on handling merging values for hash of hashes by hiyall

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.