my @parents = qw( a b c );
my @children = qw( 1 2 3 4 );
my %abc :shared;
%{ $abc{ $_ } //= &share({}) } = map{ $_ => 1 } @children for @parents
+;
pp \%abc;
Which prints: do {
my $a = {
# tied threads::shared::tie
a => {
# tied threads::shared::tie
1 => 1,
2 => 1,
3 => 'fix',
4 => 'fix',
},
b => {
# tied threads::shared::tie
1 => 1,
2 => 1,
3 => 'fix',
4 => 'fix',
},
c => {
# tied threads::shared::tie
1 => 1,
2 => 1,
3 => 'fix',
4 => 'fix',
},
};
$a->{a}{3} = $a->{a}{1};
$a->{a}{4} = $a->{a}{2};
$a->{b}{3} = $a->{b}{1};
$a->{b}{4} = $a->{b}{2};
$a->{c}{3} = $a->{c}{1};
$a->{c}{4} = $a->{c}{2};
$a;
}
|