http://qs321.pair.com?node_id=631358

isync has asked for the wisdom of the Perl Monks concerning the following question:

I need to query the wisdom of the perl monks...

I've got a script which I switched over to Parallel::ForkManager yesterday and after a flawless start I begin to see where the little troubles are.

I am using a "global" hash to store some data. As long as the for loop was kept inside the script on runtime everything went normal. But as soon as I used the ForkManager, each loop is its own entity (as I understand it) and the test for exist of certain keys always fails. Is that observation true?

How am I able to let a (detached/forked) sub access data from the initiating parent process/script. (Maybe its just a bug I missed and it should work out of the box...) Or is my only chance to implement a simple communication system. Any hints for that? Modules, tips?
my %hash = (test => 1); my %otherhash; use Parallel::ForkManager; my $pm = new Parallel::ForkManager(5); for(1..10000){ my $pid = $pm->start() and next; # some operations involving waiting etc. if(exists($hash{test}){ # this exist test always fails! } # write some data to otherhash $otherhash{test} = 123; $pm->finish(); } # the data 123 never arrives here...: print $otherhash{test}; ...