X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlfaq5.pod;h=49a348a81c7a8e8890936426cbcd61ed200f0a6a;hb=0dfdcd8a63a82bd61087d84a6f130e03a4b20ed9;hp=be1039012093fb68aad920653daaaf23bc90b886;hpb=793f5136aceac628d0f8aee41ccb49204963e443;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlfaq5.pod b/pod/perlfaq5.pod index be10390..49a348a 100644 --- a/pod/perlfaq5.pod +++ b/pod/perlfaq5.pod @@ -141,6 +141,7 @@ temporary files in one process, use a counter: my $count = 0; until (defined(fileno(FH)) || $count++ > 100) { $base_name =~ s/-(\d+)$/"-" . (1 + $1)/e; + # O_EXCL is required for security reasons. sysopen(FH, $base_name, O_WRONLY|O_EXCL|O_CREAT); } if (defined(fileno(FH)) @@ -427,8 +428,8 @@ To open file for update, file must not exist: To open a file without blocking, creating if necessary: - sysopen(FH, "/tmp/somefile", O_WRONLY|O_NDELAY|O_CREAT) - or die "can't open /tmp/somefile: $!": + sysopen(FH, "/foo/somefile", O_WRONLY|O_NDELAY|O_CREAT) + or die "can't open /foo/somefile: $!": Be warned that neither creation nor deletion of files is guaranteed to be an atomic operation over NFS. That is, two processes might both @@ -924,7 +925,7 @@ There's also a File::Tail module from CPAN. If you check L, you'll see that several of the ways to call open() should do the trick. For example: - open(LOG, ">>/tmp/logfile"); + open(LOG, ">>/foo/logfile"); open(STDERR, ">&LOG"); Or even with a literal numeric descriptor: