these lines of your code are where the problem lies

    -Home   => `pwd`,
    -Flags  => DB_INIT_CDB | DB_INIT_MPOOL,

First, remember that `pwd` will return the current directory with a line
feed at the end. If you use a directory path without a trailing newline, it
will work ok.

Next, you need to tell Berkeley DB to create the environment,

    -Flags  => DB_CREATE| DB_INIT_CDB | DB_INIT_MPOOL,

On a more general note, when you open the environment and any databases, you
should always check that they succeeded.

my $env = new BerkeleyDB::Env
        -Home   => $home,
        -Flags  => DB_CREATE| DB_INIT_CDB | DB_INIT_MPOOL,
        -Verbose => 1
 or die "can't open env: $BerkeleyDB::Error\n";

my $db  = new BerkeleyDB::Hash
        -Filename       => 'test.db',
        -Flags          => DB_CREATE,
        -Env            => $env
     or die "can't open database: $BerkeleyDB::Error\n";
