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

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

  • Comment on Storable::dclone maintains Readonly's readonlyness

Replies are listed 'Best First'.
Re: Storable::dclone maintains Readonly's readonlyness
by gellyfish (Monsignor) on Aug 04, 2006 at 14:28 UTC

    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
by diotalevi (Canon) on Aug 04, 2006 at 15:57 UTC

    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.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊