I'm using ActiveState Perl 5.8.8 820, with DBM:Deep 0.983 on Windows
XP w/SP2 and all latest hotfixes installed.
The problem I'm having seems to be related to the \%testhash element
at the end of @old and @same. If I change that to it's own hash, the
problem disappears.
On Jan 4, 2008 5:03 PM, Chas. Owens <[EMAIL PROTECTED]> wrote:
> On Jan 4, 2008 9:13 AM, Roman Daszczyszak <[EMAIL PROTECTED]> wrote:
> snip
> > 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?
> snip
>
> Hmm, it seems to work for me. The output of the following code is
>
> 144.1 => [ 00-99-48-AF-46-43, W117, 1, 1197390385, { alice => 20, bob
> => 23, }, ]
> 145.2 => [ 00-99-48-AF-46-43, W117, 1, 1197390385, { alice => 20, bob
> => 23, }, ]
> 146.3 => [ 00-99-48-AF-46-43, W117, 1, 1197390385, { alice => 24, bob
> => 23, }, ]
>
> Which seems to be right and I am not getting any errors or warnings.
> What version DBM::Deep are you using (I just installed from CPAN)?
> What version of Perl are you using (5.8.4 for me). Which OS are you
> on (OS X 10.4 for me)?
>
> #!/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}};
>
> for my $key (sort keys %$database) {
> print "$key => [ ";
> for my $elt (@{$database->{$key}}) {
> if (ref $elt) {
> print "{ ";
> print map { "$_ => $elt->{$_}, " } sort keys %$elt;
> print "}, ";
> } else {
> print "$elt, ";
> }
> }
> print "]\n";
>
> }
>
> 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);
> }
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/