Help for this page

Select Code to Download


  1. or download this
    use Fcntl qw(:DEFAULT :flock);
    use DB_File;  # demo purposes only; any db is fine
    ...
    
    tie(%hash, "DB_File", $DBNAME, O_RDWR | O_CREAT)
        or die "can't tie $DBNAME: $!";
    
  2. or download this
    untie %hash;    # must close database before lockfile
    close DBLOCK;   # safe to let go of lock now