http://www.perlmonks.org?node_id=1011320


in reply to Re^2: Shared hash within shared hash of hash???
in thread Shared hash within shared hash of hash???

Do i need to use lock $hash{foo} ; or lock ( \%hash ) ; if foo is used as shared_clone ?
You only need locking to ensure the consistency of your own data when shared between threads. Perl already does its own internal locking on shared structures to ensure internal consistency. So for example
my %h : shared; $h{foo} = share ({}); ... $h{foo}{bar} = 1; # in thread 1 $h{foo}{bar} = 2; # in thread 2
Here, there is no locking, so $h{foo}{bar} may end up as 1 or 2; but it won't end up as something else; nor will the {foo} or the {bar} slots of the respective hashes get corrupted.

Dave.