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).
In reply to Re: references and :shared
by jasonk
in thread references and :shared
by playingwithbots
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |