KWPro.net

Storable's Many Uses
By: conark
Published On: 5-23-2005

Found an interesting copying technique when you have a large data structure that contains code references. Use storable's dclone method: use Storable; # these lines are necessary for the code refernces to be copied; also it only works for certain versions. $Storable::Deparse = 1; $Storable::Eval = 1; %my::data:structure = %{Storable::dclone(\%your:data:structure)}; this allows me to replicate the two data structures. i encountered a problem where if i just tried to copy one hash to another like: %my:data::structure = %your::data::structure; that you would encounter a problem when dealing with references (not just code references). both are pointing to the same spot in memory, so your copy, if you want to localize it, won't work without a little aid.

Tags: perl
AddThis Social Bookmark Button Sphere: Related Content

Trackbacks: (Trackback URL)

No Comments Posted Yet
July [August] September
Sun Mon Tue Wed Thu Fri Sat
31 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 1 2 3