use strict; use warnings; use BerkeleyDB; my $env = get_environment(); my $db = BerkeleyDB::Btree->new ( -Filename => 'my_file.db', -Flags => DB_CREATE, -Env => $env ) or die "Couldn't open database at my_file.db: $BerkeleyDB::Error"; # the database now supports concurrant access. You'd # just open it in each thread and use it. See # http://www.sleepycat.com/docs/ref/cam/intro.html # for info on the concurrant system. # You can also do nested transactions and logging. See # http://www.sleepycat.com/docs/ref/transapp/intro.html # and continue next otherwise just read the docs from the # table of contents. sub get_environment { BerkeleyDB::Env->new ( -Flags => DB_CREATE | DB_INIT_MPOOL | DB_INIT_CDB ) or die "Couldn't initialize BerkeleyDB environment: $BerkeleyDB::Error"; }