Keep It Simple, Stupid | |
PerlMonks |
Merging multidimensional hashes from forks to parent hashby Speed_Freak (Sexton) |
on Jul 12, 2018 at 17:35 UTC ( [id://1218395]=perlquestion: print w/replies, xml ) | Need Help?? |
Speed_Freak has asked for the wisdom of the Perl Monks concerning the following question: 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.
Before the forking happens, I define the parent hash as %parent = (); 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. 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.
Back to
Seekers of Perl Wisdom
|
|