Hi all,
I am trying to create a test script for some work I'm trying to do
with Data::Compare using DBM::Deep, but the test code is acting flaky
and I'm not sure why.
In a previous (and working) script, I have a DBM::Deep hash keyed
using IP addresses. Inside the hash is an array that contains several
values including an array reference and a hash reference. This works
fine.
The test script is a different story. Here's the code:
-------------------------------
#!/perl/bin/perl
use strict;
use warnings;
use Data::Compare;
use DBM::Deep;
my $database = &OpenDB("test.db");
my %testhash = ( 'bob' => 23, 'alice' => 20 );
my @old = ("00-99-48-AF-46-43", "W117", 1, 1197390385, \%testhash);
my @same = ("00-99-48-AF-46-43", "W117", 1, 1197390385, \%testhash);
my %newhash = ( 'bob' => 23, 'alice' => 24 );
my @new = ("00-99-48-AF-46-43", "W117", 1, 1197390385, \%newhash);
my $ip1 = "144.1";
my $ip2 = "145.2";
my $ip3 = "146.3";
$database->{$ip1} = [EMAIL PROTECTED];
# Uncomment the line directly below to generate error
# $database->{$ip2} = [EMAIL PROTECTED];
# $database->{$ip3} = [EMAIL PROTECTED];
my @test_old = @{$database->{$ip1}};
# my @test_same = @{$database->{$ip2}};
# my @test_new = @{$database->{$ip3}};
sub OpenDB
{
# Argument(s): A string containing the database filename to be used.
# Returned: A scalar reference holding the database object.
# Globals: None.
my ($filename) = @_;
my $db = DBM::Deep->new(
file => $filename,
locking => 1,
autoflush => 1 ); # Test: see if removing this increases speed
return($db);
}
-------------------------------
The above code works as-is, but if I uncomment the line(s) above
(marked with a comment), I get the error: DBM::Deep: Cannot store a
tied value.
Why is that?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/