open my $FH, ">the_file"; # zero-byte the file flock($FH, LOCK_EX); # and Then lock it...