Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: can't manage to use BerkeleyDB::Env

by Anonymous Monk
on Aug 23, 2012 at 10:45 UTC ( #989273=note: print w/replies, xml ) Need Help??


in reply to Re^2: can't manage to use BerkeleyDB::Env
in thread can't manage to use BerkeleyDB::Env

Well, according to the docs, it is, provided you follow the docs (use flags)
#!/usr/bin/perl -- use strict; use warnings; use Data::Dump; use BerkeleyDB; for my $opts ( [], [-Flags => DB_CREATE| DB_INIT_CDB | DB_INIT_MPOOL] + ){ my $env = BerkeleyDB::Env->new( -Home => './home', @$opts, ) or warn "cannot open environment: $BerkeleyDB::Error\n"; dd $env, [ glob './home/*' ]; } __END__

On first run it doesn't exist, so first try, without flags, fails -- you need flags to initialize

$ perl berkeleydb.env.pl cannot open environment: No such file or directory (undef, []) ( bless([12346044], "BerkeleyDB::Env"), [ "./home/__db.001", "./home/__db.002", "./home/__db.003", "./home/__db.004", ], )

On second run both tries work, because its already initialized

$ perl berkeleydb.env.pl ( bless([10087228], "BerkeleyDB::Env"), [ "./home/__db.001", "./home/__db.002", "./home/__db.003", "./home/__db.004", ], ) ( bless([12336228], "BerkeleyDB::Env"), [ "./home/__db.001", "./home/__db.002", "./home/__db.003", "./home/__db.004", ], )

Replies are listed 'Best First'.
Re^4: can't manage to use BerkeleyDB::Env
by grondilu (Friar) on Aug 23, 2012 at 10:54 UTC

    Ok, thanks.

    I was mis-leaded by the following statement in the BerkeleyDB man page:

    All the parameters to the BerkeleyDB::Env constructor are optional.

    Well, not so true then.

      Well, not so true then.

      :) Well sure its true :) its just that success isn't guaranteed -- its like open, even filename is optional, but it doesn't mean you'll open a file

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989273]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2021-01-23 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?