good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Sharing multitiered hash amongst multiple threads?by BrowserUk (Patriarch) |
on Jan 28, 2006 at 21:51 UTC ( [id://526219]=note: print w/replies, xml ) | Need Help?? |
You can only assign references to shared arrays and hashes into shared hashes. You can either declare them shared and assign a reference:
Which is simple but often inconvenient. Or you can use threads::shared::share to them before assignment. There are two caveats with the second approach.
You can make life a little easier by bypassing the prototypes using $sharedHash{ key } = &share( {} ) and $sharedHash{ key } = &share( [] ), but don't be tempted to do $sharedHash{ key } = &share( [ 'some', 'stuff', 'here' ] );because the contents will be discarded. An example
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|