Subject: | shifting from an array with nested arrays causes an exception |
It's possible that I've missed something in the docs that tells me how
to work around or correct this issue, but I haven't found it.
To recreate the issue:
use DBM::Deep;
$x=DBM::Deep->new("test.db");
push @{ $x->{a} }, [ rand(100), rand(100), rand(100) ] for 1 .. 3;
$y=$x->{a};
$z = shift(@$y);
print @$z'
The code never completes because it dies when it tries to run
shift(@$y), with this error:
DBM::Deep: Cannot store something that is tied.
I presume (without having dug through the code) that this is being
caused because shift() is reassigning the array to $y, but since the
sub-elements are arrays that have been blessed into DBM::Deep, it's
tripping on this error condition.
I've run into that problem a number of times while performing a few
operations involving moving values around and such. In most cases
previously, it's been easy enough to clean up the data by copying the
data out into a clean array or hash and then storing a new reference to
the clean data. However, that's not always easy.