Storable::dclone maintains Readonly's readonlyness
bennymack
created: 2006-08-04 10:02:05

Hello all,

I've recently discovered that if I make an array readonly with Readonly::Array and then make a deep copy of it with Storable::dclone, the readonlyness is maintained in the deep copy.

I would like the copy not to be readonly, however. And I'm not too keen on unlocking the array in the off chance that it wasn't cloned first. Is there a better way to copy the array perhaps? From what I've seen, using Data::Dumper and eval is about half as fast as dclone and seems hackish.

Thanks in advance!

-bmb

Re: Storable::dclone maintains Readonly's readonlyness
created: 2006-08-04 10:28:09

You might be able to "unlock" the array in a STORABLE_thaw hook, see the section entitled "WIZARDS ONLY" in the Storable documentation.

/J\

Re: Storable::dclone maintains Readonly's readonlyness
created: 2006-08-04 11:57:35

I'll second gellyfish. dclone is your best way to copy the data and if you want a less perfect copy just make those edits to the result.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

perlmonks.org content © perlmonks.org and bennymack, diotalevi, gellyfish

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03