#! perl -slw use strict; use threads; use threads::shared; use Data::Dump qw[ pp ]; sub helper { my $ref = shift; ## Not needed if no more that one thread will access each subhash ## lock $ref; $ref->{NEW_KEY} = 1; } sub my_sub { my $ref = shift; my @threads = map async( \&helper, $_ ), values %{ $ref }; $_->join for @threads; } my $hoh = { A => shared_clone( { NAME => 'aa' } ), B => shared_clone( { NAME => 'bb' } ), }; pp $hoh; my_sub( $hoh ); pp $hoh; #### C:\test>junk39 { A => { # tied threads::shared::tie NAME => "aa", }, B => { # tied threads::shared::tie NAME => "bb", }, } { A => { # tied threads::shared::tie NAME => "aa", NEW_KEY => 1, }, B => { # tied threads::shared::tie NAME => "bb", NEW_KEY => 1, }, }