IO::AtomicFile

Description

Writes a file which is updated atomically.

This module is intended for people who need to update files reliably in the face of unexpected program termination. For example, you generally don't want to be halfway in the middle of writing /etc/passwd and have your program terminate! Even the act of writing a single scalar to a filehandle is not atomic.

Note: To ensure that problems do not go undetected, the "close" method done by the destructor will raise a fatal exception if the rename() fails. The explicit close() just returns undef.

You can also decide at any point to trash the file you've been building.