Hi,
I'm soooo stuck please help me. I've been trying to share this array forever but it does not work for me. :(
I need to make this work but I have to use "share" here, I can not simply return the variable. any idea how I can fix this?
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 "inva +lid 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]); }
and here is my output when I run this
~/my_perl_test> perl sharingpoes2.pl $VAR1 = [ [] ]; $VAR2 = [ [] ]; $VAR3 = [ [] ]; $VAR4 = [ [] ]; $VAR5 = [ [] ]; $VAR6 = [ [] ];
I really really appreciate all your help.
thanks a lot
In reply to sharing array please help by bebe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |