successor1221955 has asked for the wisdom of the Perl Monks concerning the following question:

I'm upgrading my application from a SDBM_File database to a BerkeleyDB database. To experiment with the Perl Module I wrote the following simple script:
#!/usr/bin/perl use BerkeleyDB; my $env = new BerkeleyDB::Env -Config => { DB_DATA_DIR => "/usr3/mxp/dev/database", DB_LOG_DIR => "/usr3/mxp/dev/log", DB_TMP_DIR => "/tmp" }, -Verbose => 1, -ErrFile => *STDOUT or die "Database environment ini +tialization failed : $!";
The program returned:
Database environment initialization failed : No such file or directory at /usr3/mxp/dev/src/txt2bkdb line 5.
All the directories listed under the -Config keyword exist. Any idea fellow monks what in the world is happening here? Could it be a problem in the installation of the BerkeleyDB.pm? If tried removing all option specification and I still get the same error! In another script, I bypassed the environment command and went directly to BerkeleyDB::Hash which returned no errors!

Replies are listed 'Best First'.
Re: Berkeley Database Question
by pboin (Deacon) on Mar 23, 2005 at 20:10 UTC

    Looks like there may be some build problems with 0.26 right now. (I certainly can't build on Debian w/ 2.6.10). Check out the CPAN bug report.

    Update: I got a good build after apt-get install libdb4.1 libdb4.1-dev.

    Update 2: Looks like your 'or die' is getting passed into the ErrFile. That's not part of the filename! Try moving it out of the new() alltogether.

    This seems to return OK:

    #!/usr/bin/perl use BerkeleyDB; use strict; my $env = new BerkeleyDB::Env -Config => {DB_DATA_DIR => "/tmp", DB_LOG_DIR => "/tmp", DB_TMP_DIR => "/tmp"}, -Verbose => 1, -Flags => DB_CREATE -ErrFile => *STDOUT ; if (not defined($env)) { die "Database environment initialization failed: $!"; }
Re: Berkeley Database Question
by PodMaster (Abbot) on Mar 23, 2005 at 23:01 UTC
    Searching the BerkeleyDB documentation for $! I imediately came accross  or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;. So, what does your $BerkeleyDB::Error say?

    update: Try adding some flags

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.