romandas has asked for the wisdom of the Perl Monks concerning the following question:
My questions, as shown in the comments, are:#!/perl/bin/perl use strict; use warnings; use DBM::Deep; use Data::Dumper; unlink("test.db"); my $database = DBM::Deep->new( file => "test.db", locking => 1, autoflush => 1 ); # Test array that contains a hash reference as an element my @array = ("Mac Address", "PCNAME", 1, 1187000400, { 'bob' => 23, ' +alice' => 20 }); print("\@array\n", Dumper(\@array)); # Shows the contents of the ar +ray, with no blessed references and nothing tied to the DBM::Deep dat +abase $database->{141} = \@array; # Assigns the array reference as a valu +e of the DBM::Deep database hash print("\@array\n", Dumper(\@array)); # Now the original array's int +ernal hash is tied or blessed or something to the database my $temp = $database->{141}->export; # Export should return a refer +ence to an array in which the internal hash is not tied to the databa +se anymore print("\$temp\n", Dumper($temp)); # Dumper shows no tied or blessed + hash; seems like it worked. my @new_array = @{ $temp }; # Dereferencing the array reference to +reconstitute the array. print("\@new_array\n", Dumper(\@new_array)); # The new array's hash + reference is normal. @array = @{ $temp }; # Assigning the array reference to the origina +l array variable.. should work fine. print("\@array\n", Dumper(\@array)); # This prints a hash reference + that is still tied to the database. WTF? my @array = @{ $temp }; # Assigning the array reference to the orig +inal array variable but redeclaring it using my. print("\@array\n", Dumper(\@array)); # This works... Why is redecl +aring the variable important? Why doesn't the reassignment work?
|
---|