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

In attempting to tie a DB_File with:
my $path_to_file= "/tmp/foo.db"; my $result= {}; tie %$result, "DB_File", $path_to_file, O_RDWR|O_CREAT, 0666, $DB_TREE + or die "Error: $!";

I was getting "Error: File exists" when the file did not. However, I found the file "/tmp/__foo.db" did exist. Does this mean that DB_File is creating this file and it is being left around when the script does not clean up?

If my assumption is correct, I would like to know so that I can make sure I clean up those files if they exist after a crash or unpredicted shutdown.

The reason the script is not cleaning up is that it is being started in inittab (Linux) with respawn and it is exiting for no apparent reason.

# inittab 1:45:respawn:/path/start.sh # start.sh # deal with old log files and then cd /proper_place /proper_place/script.pl > /logs/stdout 2> /logs/stderr
I'm logging stderr and stdout but I get nothing in either. Any thoughts on either problem would be greatly appreciated.

Replies are listed 'Best First'.
Re: DB_File problem
by shmem (Chancellor) on Jul 07, 2006 at 15:00 UTC
    I get the error type parameter is not a reference, because $DB_TREE should be $DB_BTREE.

    This should be visible via STDERR. You should find this messages in the log of your syslog, probably /var/log/messages (or /logs/stderr in your case, provided /logs exists and is writeable)

    And no, neither perl nor DB_File will prepend underscores to a file name by themselves.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

      My mistake. The DB_TREE bit was a typo. In trying to make the sample case boil down to the simplest version, I goofed on cut and paste. I have $DB_BTREE after all.

      I am trying to reproduce the "__foo.db" bit but so far I am not able. This is the reason I asked here. If I was able to reproduce it and just remove the "__" file, I would be okay with that.

      The logs files do exist and other information is being placed in them.

      Thanks anyway.

        So, typo fixed in your posted script, it fails in the way described? Mind to post what's in the logs (if relevant to the problem)?