I apologize, I did not realize the code was essential to solving the problem. The following is a sample code because the original code is much too long to list:

# First we must create our data structure. $master_matrix->[0]->{'animal'} = "tiger"; $master_matrix->[0]->{'size'} = "big"; $master_matrix->[0]->{'speed'} = "fast"; $master_matrix->[1]->{'animal'} = "bear"; $master_matrix->[1]->{'size'} = "bigger"; $master_matrix->[1]->{'speed'} = "medium"; $master_matrix->[2]->{'animal'} = "sobes"; $master_matrix->[2]->{'size'} = "tiny"; $master_matrix->[2]->{'speed'} = "quick"; $master_array = [5, 7, 9, 12, 4]; # Now we can do the parallel processing. use IO::Handle; use Data::Dump; $max_core = 1; foreach $core_number (1..$max_core) { pipe ($reader, $writer); $writer->IO::Handle::autoflush(1); $pid = fork(); if ($pid) { # This is the parent process close $writer; undef $master_matrix; undef $master_array; $child_process_numbers{$core_number} = $pid; $child_file_handles{$core_number} = $reader; undef $reader; } elsif ($pid == 0) { # This is the child process close $reader; print "child master matrix: $#{$master_matrix}\n"; $frozen_data = Data::Dump->pp($master_matrix); print $writer $frozen_data; close $writer; exit(0); } else { # Process is undefined die "couldn't fork: $!\n"; }; }; foreach $core_number (keys %child_process_numbers) { $pid = $child_process_numbers{$core_number}; $reader = $child_file_handles{$core_number}; $frozen_data = <$reader>; undef $reader; $thawed_data = eval($frozen_data); print "thawed data: $#{$thawed_data}\n"; waitpid($pid, 0); }; exit;

I have decided to use Data::Dump because of the Storable "version" problem (discussed on your website and several others). The code is set up to generate multiple children, but I have it set to only generate one for simplicity. The code is able to produce the correct answer if I use the $master_array, but it does not produce the correct answer if I use the $master_matrix (an array of hashes). Hopefully this will help everyone.

Thank you Monks for all of your help.

Scott


In reply to Re: Pipe Complex Data Structure by Anonymous Monk
in thread Pipe Complex Data Structure by Anonymous Monk

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.