XP is just a number | |
PerlMonks |
Dump, Dup or Copy an objectby turo (Friar) |
on Feb 22, 2006 at 13:02 UTC ( [id://531943]=perlquestion: print w/replies, xml ) | Need Help?? |
turo has asked for the wisdom of the Perl Monks concerning the following question:
Hi, monks! For example, if i have this array: Which is compossed by two references to other arrays (ARRAY(0x814cc20), ARRAY(0x819eae0)) p.e. I want to make a new copy of that array, and a new copy of each sub-element referenced, with the same content. Dumping the element to a file, and re-reading is the only way? ... or does it copy the references to a file, so when you load it, perl can allocate the elements on the same memory position? ... In c++, for make a copy of an object programmers must implement the copy constructor ... I think, i can do the same in perl (with little problems like, how can I allocate new memory, or how can I make the same as memcpy ... bad habits ^_^>), but after, i've saw the power of the Dumpvalue module ... i cant think in other way to do it ...
Thanks, :-)
perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'
Back to
Seekers of Perl Wisdom
|
|