Orchew has asked for the wisdom of the Perl Monks concerning the following question:

Hi everybody! I need to overwrite a file that other processes read from time to time, so I don't want it to end up being read when it's half written.

So I'm looking for a module that handles this, basically writes to a temp file, then unlinks the old file, and renames the tempfile to the old name.

Does this exist or do I have to write it? Thanks!

P.S. The double buffer reference is to graphics redraws, where you don't want to see a flash.

my $copilot = [ "Perl" ]
bless $copilot;
  • Comment on "double buffered" file overwrite (like rsync)

Replies are listed 'Best First'.
Re: "double buffered" file overwrite (like rsync)
by Fletch (Bishop) on Mar 03, 2009 at 03:56 UTC

    Erm, what of the combination of File::Temp and rename doesn't do what you need?

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: "double buffered" file overwrite (like rsync)
by Anonymous Monk on May 01, 2009 at 19:37 UTC
    There's a new module that does this apparently, I'm going to try it out... File::AtomicWrite.