#!/usr/bin/perl use Fcntl qw( :flock ); my $tempfile="/tmp/$$.temp"; print "Content-type: text/html\n\n"; print "Testing flocking now.
\n"; open(TMP, "+> $tempfile") or die "Could not open tempfile: $!"; flock(TMP, LOCK_EX|LOCK_NB) or die "no lock: $!"; seek(TMP, 0, 0); print TMP "Blah blah blah"; # just to test close(TMP); unlink $tempfile; print "That seemed to go just fine.\n";