Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: refering to 1 shared hash from another

by Random_Walk (Prior)
on Apr 24, 2013 at 12:46 UTC ( [id://1030388]=note: print w/replies, xml ) Need Help??


in reply to Re^3: refering to 1 shared hash from another
in thread refering to 1 shared hash from another

use strict ; use warnings; use threads; use threads::shared; use Data::Dumper; my %HoH :shared; my %hash :shared; $hash{pre_key} = "Before"; $HoH{hash}=\%hash; $hash{post_key} = "After"; if (\%hash eq $HoH{hash}) { print "OK\n"; } else { print "Copied, I suspect\n"; } print Data::Dumper->Dump ([\%hash], ["hash"]); print Data::Dumper->Dump ([$HoH{hash}], ["HoH"]); print "But looks like they still stay in sych\n
Output
Copied, I suspect $hash = { 'pre_key' => 'Before', 'post_key' => 'After' }; $HoH = { 'pre_key' => 'Before', 'post_key' => 'After' }; But looks like they still stay in sych

Update

I just read the docco for threads::shared and found this gem, which explains your issue:

Using refaddr()) is unreliable for testing whether or not two shared references are equivalent (e.g., when testing for circular references). Use is_shared(), instead:

There is more detail, and an example of the correct way to test in said docco

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1030388]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-24 18:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found