in reply to BerkeleyDB locks

I'm not terribly familiar with the way BerkeleyDB's locking works (and it seems like there should be a way to take care of this locking problem from within BerkeleyDB), but the big question for me was what you mean by the process "crashing." If it is just you (or some module you use) calling "die", then you can use an END {} block (see perlmod) to do the cleanup necessary to release the lock on the DB. If it's the actual perl interpreter crashing you have much bigger problems, and you should solve that problem first before worrying about the file locking.

Another option might be using a module like LockFile::Simple to lock the hash independent of BerkeleyDB semantics.