in reply to Re^6: forked::shared with hashes?
in thread forked::shared with hashes?
Does that work bidirectionally?Yes, it does.
UPDATE: Sample code:
Output:use warnings; use strict; use forks; use forks::shared; my %GLOBALHASH : shared; share (%GLOBALHASH); my $pid = fork (); if (!$pid) { # child $GLOBALHASH{OILPRICE} = 100; sleep 1; print "Gold price from the parent: $GLOBALHASH{GOLDPRICE}\n"; exit 0; } elsif ($pid) { # daddy $GLOBALHASH{GOLDPRICE} = 200; sleep 2; print "Global Oils Price is now: " . $GLOBALHASH{OILPRICE} . " dol +lars\n"; }
Gold price from the parent: 200 Global Oils Price is now: 100 dollars
|
|---|