in reply to Re-runnably editing a file in place

I think that the most reliable sequence would be:

  1. Edit the file, reading from the original, writing to the temporary file
  2. Set the permissions on the temporary file to those of the original file
  3. Rename the temporary file to the original filename.

Unless there is an interuption during the final renaming of the file your file should be in a sensible state whatever happens.

Update: Sorry, that's what you're doing already, with the necessary step of making the file readable to move it. I'm not very awake at the moment. Just ignore me.

I'm not sure if there would be any advantage in using the move function in File::Copy rather than rename. Is it more portable or reliable?