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.
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail