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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.