
Cure
User
Apr 19, 2000, 10:31 PM
Post #2 of 2
(727 views)
|
Hi use strict; use Fcntl ':flock'; use DB_File; my %temp; my $db = tie %temp, 'DB_File',$easylist, O_CREAT|O_RDWR, 0666, $DB_HASH or die "Could not tie hash:$!"; ##### Exclusively lock the database to ensure no one access it my $fd = $db->fd(); open DATAFILE, "+&<=$fd" or die "Cant safely open file: $!\n"; flock( DATAFILE, LOCK_EX) or die "Unable to acquire lock $!. Aborting"; close the database undef $db; untie %database; ### Close the filehandle to release the lock close DATAFILE; Cure
|