in reply to Re: sharing array of arrays between threads
in thread sharing array of arrays between threads

You should generally be using subroutine() instead of &subroutine(), i.e. no leading ampersand (&). See perlsub.

Actually, if you read threads::shared, you'll find that his use of &share([]); is exactly the correct thing to do in this case.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^3: sharing array of arrays between threads
by kcott (Archbishop) on Aug 10, 2012 at 10:23 UTC

    ++ Thanks for pointing that out. I've updated my node.

    -- Ken

      Hi everyone thank you so much for your help....
      Thanks for the tutorials... I'm trying to correct my code ...
      I've successfully tried sharing array X (when X is a one_dim array)... but I'm still having the hardest time converting this code so that array X is looks like below


      X[0] = ("QWE", "RTYU" ,"IOP")
      X[1] = ("QSWE", "TYU" ,"IKOP", "BVC")
      X[2] = ("QE", "TYU")
      X[3] = ("QSWE", "TYU" ,"IKOP", "BVC", "LMNB")
      .
      .
      .

      here is the code that works for one_dim array X

      my @X : shared = ();


      sub abc {
      my $Var2;
      .... Here the string in $Var2 gets updated everytime abc is called ....
      push(@X, $Var2);
      }


      here is how I'm changing this

      my @X : shared = ();

      sub abc {
      my $Var2;
      .... Here the string in $Var2 gets updated everytime abc is called
      push(@{X[$i]}, $Var2);
      }

      I'm still confused, I'm not quite sure how to share the arrays inside of X correctly.
      Could you please help me with that?I greatly appreciate all your help.

      thank you so much