Based on others' comments, I found the solution to the problem. I just added a db_close(), and the problem is really, truly gone. For good measure, I put a db_sync() in as well.
Why db_close isn't necessary with 3.x, but is with 4.0 is the weird part. Maybe this suggests a bug in 4.0? Or is it just bad style to have left it out in the first place? I was under the impression that the untie/undef should have accomplished this implicitly within BerkeleyDB.pm. Here is the modified test script: --------- TEST SCRIPT --------- #!/usr/bin/perl use strict; use BerkeleyDB qw( DB_CREATE DB_INIT_MPOOL DB_INIT_CDB ); # Change me to something appropriate for your system my $dir='/home/httpd/some/directory'; system( "rm $dir/__db* $dir/TESTdb" ); foreach( 1..5 ) { my $env = open_env($dir); my %hash; my $db = open_db( "TESTdb", \%hash, $env ); $db->db_sync(); ### NEW $db->db_close(); ### NEW untie %hash; undef $db; undef $env; } print "HTTP/1.1 200\nContent-type: text/plain\n\n"; print `db_stat -c -h $dir`; print "\n"; sub open_env { my $env = new BerkeleyDB::Env( -Flags=>DB_INIT_MPOOL|DB_INIT_CDB|DB_CREATE, -Home=> $_[0], ); die "Could not create env: $! ".$BerkeleyDB::Error. "\n" if !$env; return $env; } sub open_db { my( $file, $Rhash, $env ) = @_; my $db_key = tie( %{$Rhash}, 'BerkeleyDB::Btree', -Flags=>DB_CREATE, -Filename=>$file, -Env=>$env ); die "Can't open $file: $! ".$BerkeleyDB::Error."\n" if !$db_key; return $db_key; } Dan Wilga [EMAIL PROTECTED] Web Technology Specialist http://www.mtholyoke.edu Mount Holyoke College Tel: 413-538-3027 South Hadley, MA 01075 "Seduced by the chocolate side of the Force"