On m�ndag, juli 22, 2002, at 03:23 , Ray Hilton wrote:

>
> Seem to be getting a problem when trying to share hashes, I think I am
> doing it write, or maybe this is a known problem?  This is the kind of
> thing I am trying to do in a module called Thread/Manage.pm
>
> use threads;
> use threads::shared;
>
> my %hash :shared;
>
> function foo {
>       my ($key, $value) = @_;
>       $hash{$key} = $value;
> }
>
> This then returns:
>
> Invalid value for shared scalar at Thread/Manage.pm line 52.
> A thread exited while 4 other threads were still running.
>
> It seems as though perl sees $hash{} as a scalar, and not the hash that
> was declared above.  Any ideas?
>
> Cheers,
>
> Ray

Hi,

Aside from the fact that $hash{$key} is a scalar :-), if $value is a 
reference it needs to be shared for the assign to work.

Regards,
Arthur

Reply via email to