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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.