- or download this
open my $FH, ">the_file"; # zero-byte the file
flock($FH, LOCK_EX); # and Then lock it...
- or download this
open my $FH, "the_file"; # open for reading
flock($FH, LOCK_SH); # lock it
...
push @lines, "new line\n"; # process the lines
print $FH for (@lines); # write them out
close $FH; # close and drop lock
- or download this
# Open a different file as a semaphore lock
...
close $FH; # close the file
close $SEM; # close and unlock semaphore
- or download this
# Open the file for locking purposes only
...
close $FH;
close $SEM; # close and unlock semaphore