Thanks to all. Some hard meditation and I've gotten to a simplified skeleton that I think solves everything. If you see anything worth warning me about, I would love to hear it.

I'm putting the proof of concept code in <readmore> tags. The work file was called "sharedanonymoushashrefs.pl", so that explains some of the naming conventions (sahr_).

#!/usr/bin/perl -w use strict; use threads; use threads::shared; use Thread::Queue; my $qQueue0 = Thread::Queue->new; my $qQueue1 = Thread::Queue->new; my $href; $href = &share({}); $href->{'a'}=1; $href->{'b'}=2; $href->{'c'}=3; $href->{'d'}=4; print "before enqueue\n"; printKeys($href); print "\n"; $qQueue0->enqueue($href); $href = &share({}); $href->{'e'}=5; $href->{'f'}=6; $href->{'g'}=7; $href->{'h'}=8; print "before enqueue\n"; printKeys($href); print "\n"; $qQueue0->enqueue($href); $qQueue0->enqueue(undef); my $sahr_thread = threads->new(\&sahr_thread, $qQueue0, $qQueue1); $sahr_thread->join; while ($href = $qQueue1->dequeue) { print "Results\n"; printKeys($href); print "\n"; } sub printKeys { my $loc_href = shift; print "KEYS : "; print(($_).' ') foreach (sort keys %{$loc_href}); print "\nvalues: "; print(($$loc_href{$_}).' ') foreach (sort keys %{$loc_href}); print "\n"; } sub sahr_thread { my ($inqueue, $outqueue) = @_; my %inhash; my $inhashref; my $outhashref; while ($inhashref = $inqueue->dequeue) { %inhash = %{$inhashref}; print "within thread - inhash\n"; printKeys (\%inhash); print "\n"; $outhashref = &share({}); %$outhashref = (%inhash); $outhashref->{z} = 9; $outhashref->{y} = 8; print "within thread - outhash\n"; printKeys ($outhashref); print "\n"; $outqueue->enqueue($outhashref); } }

In reply to Re^2: scalars, references and queues by Anonymous Monk
in thread scalars, references and queues 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.