use Fctl qw(:flock); my $fh = new IO::File("file1","r"); flock($fh,LOCK_EX) or die "can't get lock"; my $fh2 = new IO::File("file2","w"); # read fh and write fh2 (ie do a filter) # move fh2 over fh # rename("file2","file1"); doesn't work # File::Copy's move($fh2,$fh1); doens't work flock($fh,LOCK_UN);