Hans Meier (John Doe) wrote:
Tom Allison am Dienstag, 14. Februar 2006 02.28:
I was trying out some jobs with the Berkeley DB and decided to move up from
DB_File to BerkeleyDB. I don't need a lot of features, just speed.
But I keep running into a "dumb" error that doesn't make any sense to me.
untie attempted while 1 inner references still exist at ./dbm_test.pl line
31.
According to docs and the old DB_File method... I shouldn't get this
warning. I can't find anything that's not working with the code, but I
don't like errors just the same...
Any ideas?
#!/usr/bin/perl
use strict;
use warnings;
use BerkeleyDB;
use Digest::MD5 qw[md5_hex];
use Time::HiRes qw[tv_interval gettimeofday];
use Data::Dumper;
my %hash;
my $db = tie %hash, "BerkeleyDB::Hash",
-Filename => 'authentication.db',
-Flags => DB_CREATE
or die "yer fucked!\n";
for(my $x = 0; $x<10_000; $x++) {
my $y = int(1 + rand(10_000_000));
my $t = [gettimeofday];
if(exists $hash{$y}) {
my $value = $hash{$y};
print "get ";
} else {
my $value = md5_hex(@$t);
$hash{$y} = $value;
print "put ";
}
print tv_interval($t, [gettimeofday]),"\n";
}
untie %hash;
The one inner reference mentioned in the error is hold in $db :-)
What you can do:
a) Since you don't use $dh, just say
tie %hash, "BerkeleyDB::Hash";
you can always
my $db=tied(%hash);
b) put before untie %hash a
undef $db;
hth,
Hans
That simple!
Thanks!
I'm keeping the db reference so I can db_sync().
It seems to get into these lags where 6-12 records take >0.2 seconds to process.
Much longer than the typical...
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>