Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Temporary text files with File::Temp

by jwkrahn (Monsignor)
on Feb 26, 2008 at 04:26 UTC ( #670227=note: print w/ replies, xml ) Need Help??

in reply to Temporary text files with File::Temp

You can also create a temporary file with open using undef as the third argument:

open my $TEMP, '+>', undef or die "Cannot open temporary file: $!";

Comment on Re: Temporary text files with File::Temp
Download Code
Replies are listed 'Best First'.
Re^2: Temporary text files with File::Temp
by Anonymous Monk on Feb 26, 2008 at 08:40 UTC
    if teaching his students to use binmode wasn't acceptable, neither is this

      We teach binmode, for use when we expect the file to be binary. If there were a layer I could pass to binmode which turned off binary, or turned everything back to text processing (text/reset/default/native) which didn't require another module to do it, I'd be thrilled. Unfortunately this doesn't seem to be the case.

      I don't mind teaching my students that File::Temp assumes that temporary files will be binary by default. I was just hoping that someone could show me the easy, portable way we could revert that. But it doesn't seem to exist in Perl 5.10 and below. Perhaps I'll get a patch into File::Temp for 5.10.1, or alternately have some luck getting a layer for binmode which turns off binary.

      Unfortunately in-memory files isn't really what I was looking for. They're cool, but they don't really solve the problem I was having. I want to be able to write out a file to a temporary location, then when I know that it's been fully written, I want to move the file over an original atomically. This means that at no point can someone access that file and get invalid data. Old previously-valid data, sure, but never only partly-written data.

      thanks, jarich.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://670227]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2015-10-04 13:57 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (103 votes), past polls