.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "IO::AtomicFile 3"
.TH IO::AtomicFile 3 "2015-04-22" "perl v5.16.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
IO::AtomicFile \- write a file which is updated atomically
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use IO::AtomicFile;
\&
\& ### Write a temp file, and have it install itself when closed:
\& my $FH = IO::AtomicFile\->open("bar.dat", "w");
\& print $FH "Hello!\en";
\& $FH\->close || die "couldn\*(Aqt install atomic file: $!";
\&
\& ### Write a temp file, but delete it before it gets installed:
\& my $FH = IO::AtomicFile\->open("bar.dat", "w");
\& print $FH "Hello!\en";
\& $FH\->delete;
\&
\& ### Write a temp file, but neither install it nor delete it:
\& my $FH = IO::AtomicFile\->open("bar.dat", "w");
\& print $FH "Hello!\en";
\& $FH\->detach;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This module is intended for people who need to update files
reliably in the face of unexpected program termination.
.PP
For example, you generally don't want to be halfway in the middle of
writing \fI/etc/passwd\fR and have your program terminate! Even
the act of writing a single scalar to a filehandle is \fInot\fR atomic.
.PP
But this module gives you true atomic updates, via \fIrename()\fR.
When you open a file \fI/foo/bar.dat\fR via this module, you are \fIactually\fR
opening a temporary file \fI/foo/bar.dat..TMP\fR, and writing your
output there. The act of closing this file (either explicitly
via \fIclose()\fR, or implicitly via the destruction of the object)
will cause \fIrename()\fR to be called... therefore, from the point
of view of the outside world, the file's contents are updated
in a single time quantum.
.PP
To ensure that problems do not go undetected, the \*(L"close\*(R" method
done by the destructor will raise a fatal exception if the \fIrename()\fR
fails. The explicit \fIclose()\fR just returns undef.
.PP
You can also decide at any point to trash the file you've been
building.
.SH "AUTHOR"
.IX Header "AUTHOR"
.SS "Primary Maintainer"
.IX Subsection "Primary Maintainer"
Dianne Skoll (\fIdfs@roaringpenguin.com\fR).
.SS "Original Author"
.IX Subsection "Original Author"
Eryq (\fIeryq@zeegee.com\fR).
President, ZeeGee Software Inc (\fIhttp://www.zeegee.com\fR).
.SH "REVISION"
.IX Header "REVISION"
\&\f(CW$Revision:\fR 1.2 $