From: "Jay M" <[EMAIL PROTECTED]> > I am attempting to modify a script that was coded back when perl 4.xx > was the current version. This script accesses databases using DB_File > and dbmopen(). After every dbmopen and dbmclose there is a flock(). > For example. > > dbmopen(%DB, $filename, 0777) || die "Error: $!\n"; > flock(DB,2); > #insert code here > dbmclose(%DB); > flock(DB,8); > > Whenever this script run with -w I get "flock on unopened filehandle" > errors. Im wondering if the flocks are even neccessary as it appears > they arn't serving any purpose as they are right now. What purpose > could they have served?
No purpose. I guess someone did not try to run the code under -w and felt safe even though no locking was done at all. > Secondly I know that tie is now the way to access these databases and > am wondering if I could just replace all the dbmopens / flocks with > something like this instead... > > use Fcntl; > use DB_File; > tie %DB, 'DB_File', $filename, O_CREAT|O_RDWR, 0777, $DB_HASH > or die "Cannot open $filename: $!\n" ; > #insert code here > untie %DB; I would recomend looking at DB_File::Lock, Tie::DB_LockFile and Tie::DB_Lock modules. (Choose which suits you best) Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]