Subject: | Assigning a reference to itself dies |
I just updated to the latest version to fix the issue I reported a
little bit ago that was fixed in 1.003 (thanks for the prompt fix btw).
However, I ran into a different problem by accident. Assigning a value
over itself has some odd behavior, I've included a test case:
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use DBM::Deep;
use Scalar::Util qw/ reftype /;
my $dbm = DBM::Deep->new('test.db');
for my $value ( 1, 2, 3 ) {
my $ref = $dbm->{foo};
$ref = [] unless defined reftype $ref and reftype $ref eq 'ARRAY';
push @$ref, $value;
$dbm->{foo} = $ref;
print Dumper($dbm->{foo});
}
This test fails on the second iteration because of:
DBM::Deep: Cannot write to a deleted spot in DBM::Deep.
It looks like assigning a reference back into the spot it originally
came from causes issues. This isn't a problem for me, but I ran into it
while working so I thought I'd pass it along.