Unfortunately, autovivification doesn't auto-share, so you have to manually create shared elements.
#! perl -slw use strict; use threads; use threads::shared; use Data::Dumper; my %hash : shared; my $var = 'hello'; $hash{ foo } = &share( {} ); $hash{ foo }{ bleh } = 'test'; $hash{ $var } = &share( {} ); $hash{ $var }{ foo } = 'test'; print Dumper \%hash; __END__ P:\test>test $VAR1 = { 'foo' => { 'bleh' => 'test' }, 'hello' => { 'foo' => 'test' } };
Note: The &shared( {} ); syntax is required. See threads::shared for details.
In reply to Re: Re: Re: threads::shared hash
by BrowserUk
in thread threads::shared hash
by fxmakers
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |