in reply to Add hash to DB_HASH file using DB_File

It looks like you're getting tripped up by operator precendence, and are misdiagnosing (by failing to correctly diagnose) a tie failure.
tie %h,"DB_File",$users_dbm_file,O_RDWR|O_CREAT,0640,$DB_HASH || die( "Cannot tie $users_dbm_file $! \n" );
isn't doing what you expect. Unless $DB_HASH is 0, die will never get invoked. And if $DB_HASH is 0, die will be invoked, but not in the way you expect.

Ponder for a moment the different subtle between || and or. You might wish to read the SYNOPSIS in perlop.

Replies are listed 'Best First'.
Re: Re: Add hash to DB_HASH file using DB_File
by greenFox (Vicar) on Apr 09, 2001 at 15:24 UTC
    I probably overuse them a bit but if there is the smallest doubt I bracket my functions. Looking at that little knot reminds me why its a good idea :)

    --
    my $chainsaw = 'Perl';

      Bracketing your functions isn't quite the lesson I would expect you to draw from this, though it works. More flexible, in my opinion at least, is to use   somesub arg1, arg2, arg3 or die "message"; instead of   somesub arg1, arg2, arg3 || die "message"; which is really  somesub arg1, arg2, (arg3 || die "message");
        I use the parentheses.

        That is more friendly to someone who doesn't know the precedence tables by heart, and it also plays better with strict.

        As I like to say, if your code doesn't yet look like Lisp, then another pair of parentheses probably won't hurt...