open(FOO, ">/tmp/foo") || die; # You've altered the file! flock(FOO, LOCK_EX) || warn; # And now you bother to lock it?