I've been piecing this together for a while, but I'm getting stuck again. Does anyone have an idea how to merge a hash with itself?

I'm probably phrasing that wrong, but I have used Paralell:ForkManager to fork an if loop to utilize 40 threads. That if loop then creates a nested hash structure that needs to be returned. I use nfreeze from Storable to serialize the data, then I return that reference to the parent. I then dereference and thaw.

#dumper of thawed data $VAR44123 = '511879'; $VAR44124 = { 'file3232.ext' => { 'e' => 0, 'k' => '0.0031', 'i' => '26.9', 'j' => '33.0' } }; $VAR44125 = '739569'; $VAR44126 = { 'file3232.ext' => { 'e' => 0, 'k' => '0.1040', 'i' => '26.7', 'j' => '14.6' } };

Before the forking happens, I define the parent hash as %parent = ();
And I need to push each data structure into that parent hash, but I need them to merge.
The ending data structure will have the leftmost structure staying, but adding additional files to the middle structure, and corresponding datasets from the right side for each of those added files.

The problem I'm having is that I can't figure out how to use Hash::Merge to merge the parent hash with each returned hash from the forks.
I was thinking something like %parent = merge( \%parent, \%returned); but that currently gives me errors about having Reference found where even-sized list expected... but in one of my earlier iterations I didn't have errors, but that merge caused the script to go to one thread and hang until it ran out of memory.

Am I barking up the right tree here? Or should I be using something else to merge a structure like this?

cliff notes: I need to start with an empty hash, and then return multidimensional hashes from forks and compile them into the parent hash as each fork returns.


In reply to Merging multidimensional hashes from forks to parent hash by Speed_Freak

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.