in reply to references and :shared

You can share references, just not in quite the same way. Instead of my $ref : shared = {};, use my $ref = &share({});. To share a multidimensional object you will also need to share the anonymous refs in your code the same way, so for your second example you will have to do:

use threads::shared; my $ref = &share({}); $ref->{a} = &share([]); $ref->{a}[0] = something;

For shared objects you can use the same technique: my $ref = &share(someobj::new()). (Note that this is covered in the threads::shared documentation).

Replies are listed 'Best First'.
Re: Re: references and :shared
by playingwithbots (Novice) on Feb 25, 2003 at 18:31 UTC
    Thanks, that did the trick. I guess I read the ":shared" stuff and used it and never went back to check the docs for a solution.