in reply to Re^3: refering to 1 shared hash from another
in thread refering to 1 shared hash from another
Outputuse 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
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
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.
|
|---|