in reply to Re-runnably editing a file in place

Sounds like you want transactions for your files, and rather conveniently, this is just what File::Transaction provides e.g
use File::Transaction; my $ft = File::Transaction->new; $ft->linewise_rewrite($fname); ## do stuff if($file_contents_changed) { $ft->commit } else { $ft->revert }
See. the File::Transaction docs for more info.
HTH

_________
broquaint