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


in reply to Shared hash within shared hash of hash???

threads::shared keeps all shared variables in a separate interpreter. If you declared hash like:

my %hash : shared = ();
then hash and all its values will be stored in this dedicated interpreter. In case of:
$hash{foo} = {};
you creating anonymous hash in the current interpreter and saving reference to it in the shared interpreter which is not allowed, that's why you should create a shared copy:
$hash{foo} = shared_clone({});
Another possibility:
my %tmp : shared = (); $hash{foo} = \%tmp;