use threads::shared; use strict; use warnings; use Data::Dumper; my $tmp=meow(); #my @state : shared; #if I use this line instead I get this "invalid value for shared scalar. (since state is an array of arrays)" my @state = &share([]); for (my $i = 0;$i <6 ; ++$i) { my $row = &share([]); @{$state[$i]} = $row; } print Dumper(@state); sub meow { my $i = 0; my $j = 1; my @p = ("grey" , "striped" , "purrr", "cutest_kitty" , "meowing_kitty", "the_lord_of_the_cats"); my @k = ("smart_kitty" , "striped_sweety" , "purrr", "meowing_poes" , "social_kitty", "the_lord_of_the_poezen"); for (my $f=0; $f<6 ; $f++) { push(@{$state[$i]}, $p[$f]); push(@{$state[$j]}, $k[$f]); }