http://qs321.pair.com?node_id=409471

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Guys,

I'm trying to copy hash record structures from a global shared hash to a local copy, so the threads won't have to lock the global all the time.
Basically I have

{ package cfg; %cfg::sessions = (); threads::shared::share(%cfg::sessions); }
with data like this:
{A}{1}{C} = 1
{A}{1}{D} = 2
.
.
{B}{1}{C} = 3
{B}{1}{D} = 4
Later in a thread I want to do a deep copy of a given record eg
$myhash{A} = $cfg::sessions{A};
I've tried eg
use Storable qw(dclone); $myhash{A} = dclone($cfg::sessions{A});
but get 'Not a reference value' error.

I tried

use Clone qw(clone); $myhash{A} = clone($cfg::sessions{A});
but get a 'Segementation violation'.

In a simple (non-thread) test prog, both of the above work perfectly.
Is it possible to make these work under threads, or should I write my own fn?
Cheers
Chris