in reply to Re: forked::shared with hashes?
in thread forked::shared with hashes?
It turns out the problem has to do with the restriction that you should share scalar variables, not complex structures like hashes. So the parent can see the child's hash modifications if you do something like this:
use forks; use forks::shared; my %GLOBALHASH : shared; my %hashref : shared; $hashref = \%GLOBALHASH; $child = fork (); if (!$child) { # child $hashref->{OILPRICE} = 100; exit 0; } elsif ($child) { # daddy sleep (2); print "Global Oils Price is now: " . $hashref->{OILPRICE} . " doll +ars\n"; }
However, I've not been able to get this to work with hashes of hashes.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: forked::shared with hashes?
by choroba (Cardinal) on Apr 02, 2011 at 08:31 UTC | |
by BrowserUk (Patriarch) on Apr 02, 2011 at 12:31 UTC | |
by choroba (Cardinal) on Apr 02, 2011 at 14:29 UTC | |
by BrowserUk (Patriarch) on Apr 02, 2011 at 14:38 UTC | |
by choroba (Cardinal) on Apr 04, 2011 at 06:42 UTC |