I ran into this problem and it's plagued me for a couple weeks. I was playing with with stuff to store a bunch of stuff in a DBM::Deep file, and I'd do something to cause an error "DBM::Deep: Cannot store something that is tied". I'd change around some syntax and it would disappear. I've sorta solved the problem, but it doesn't really look like a real solution.
I figured that some other module I was using was supplying a tied object. Config::IniFiles seemed a likely candidate because it has tie methods inside it, so for awhile I blamed it and thought I had a workaround.
But the problem came back, this time without Config::IniFiles. Damn you Karl Rove!
It turns out that I was taking some data out of a DBM::Deep object and either moving it back into the object in a different form or trying to put it in a different DBM::Deep object:
#!/usr/bin/perl
use Data::Dumper; use DBM::Deep;
my $db = DBM::Deep->new( 'foo.db' );
$db->{'foo'} = [ qw(a b c) ];
my $array = $db->{'foo'};
print Dumper( $array );
$db->{'bar'} = $array;
__END__
tied
doesn't work on $array
, so when I was trying debugging statements such as print ... if tied $array
, I never saw that output. I was just guessing about who was causing the problem.$array
, so I started trying things. It turns out export
will turn the DBM::Deep thingy into a regular thingy. I got sidetracked by the line in the docs that said 'Calling the "export()" method on an existing DBM::Deep object will return a reference to a new in-memory copy of the database.' I figured that meant that I'd just get another DBM::Deep object. However, the next sentence has "...are all exported to standard Perl objects."#!/usr/bin/perl
use Data::Dumper; use DBM::Deep;
my $db = DBM::Deep->new( 'foo.db' );
$db->{'foo'} = [ qw(a b c) ];
my $array = $db->{'foo'}->export;
print Dumper( $array );
$db->{'bar'} = $array;
__END__
#!/usr/bin/perl
use Data::Dumper; use DBM::Deep;
my $db = DBM::Deep->new( 'foo.db' );
$db->{'foo'} = [ qw(a b c) ];
my $array = $db->{'foo'}->export;
$db->{'bar'} = $array; # this works
$db->{'baz'} = $array; # it's a DBM::Deep thingy again
$db->{'bar'} = $db->{'foo'}->export;
$db->{'baz'} = $db->{'foo'}->export;