Help for this page
open(FILE, ">file.dat") or die "file.dat: $!"; while ( ! flock(FILE, 2) ) { # you *might* want to consider bailing out at ... print FILE, "blah\n"; close(FILE); }