On Tue, 2002-11-05 at 14:34, Jenda Krynicky wrote:
> From: Jeremy Vinding <[EMAIL PROTECTED]>
> > On Tue, 2002-11-05 at 14:18, Jenda Krynicky wrote:
> >
> > >
> > > Because you'd have a shared reference to a private array.
> > >
> > > I believe the docs for threads.pm and Thread::Queue explain this.
> > > I'm not using Perl 5.8 yet so I can't tell.
> >
> > they don't but i guess that makes sense, however, 'perldoc
> > threads::shared', shows these examples:
> > my($scalar, @array, %hash);
> > share($scalar);
> > share(@array);
> > share(%hash);
> > my $bar = &share([]);
> > $hash{bar} = &share({});
> >
> > any suggestions as to how i can create anonymous arrays on the fly in
> > one thread and access them in another?
>
> Try
>
> enqueue( &share([1, 2, 3, 4]))
ah... i stand corrected, it does mention that in 'perldoc
threads::shared'
however when i do this:
thread 1:
$q->enqueue (&share (['bob', 'tim', 'jon']));
thread 2:
my $file = $queue->dequeue;
print "file: $file\n";
print ("bob: (", join (",", @$file), ")\n");
i get an empty array ref:
file: ARRAY(0x8505c00)
bob: ()
any other ideas?
TIA,
jjv
PS, i greatly appreciate your help.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]