Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Temporary text files with File::Temp

by Anonymous Monk
on Feb 26, 2008 at 06:16 UTC ( #670236=note: print w/ replies, xml ) Need Help??


in reply to Temporary text files with File::Temp

The use of O_BINARY where available was in the very first back-of-the-envelope suggestion from Tom Christiansen in March 2000. I admit to not really thinking through the consequences but clearly Tom imagined that most temp files would be binary rather than text. There is a bit of a backwards compatibility issue with changing the default to text, so any option would have to be provided in addition to current usage. I would be open to a TEXTMODE patch that has been tested on windows. I've never really had a Windows box for testing things on and no user has ever offered patches to get it working properly on windows.

Couple of asides:

  • tmpnam is not safe. By the time you get round to using it the file could have been taken by someone else.
  • You should be teaching people the OO interface rather than the subroutine interface. It has the advantage that the file is deleted at the correct time. This is a real problem on windows where you can't delete an open file (at least not without using Win32 calls that I can't test). Using new() and newdir() methods give much better control and more predictable file deletion instead of relying on END blocks.


Comment on Re: Temporary text files with File::Temp

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2014-09-16 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (40 votes), past polls