| Module Info
| Add a review of File-Temp
My only complaint is that File::Temp does not allow you to specify the permission bits with an option like PERMISSION => 0x666 for example. You have to do it yourself with a separate call to chmod.
Very useful module. It works just as what I need. Good job.
Nice and useful module for creating and cleaning up temporary files, safely. It provides an interface to return the filename, the filehandle, or both together. Why reinvent the wheel with your own temp file names created from $$ or whatever? Just use File::Temp!
I have used File::Temp extensively in the test suites of my CPAN modules ExtUtils::ModuleMaker and ExtUtils::ModuleMaker::PBP and will use it directly in a module to come, File::Save::Home. I strongly advocate its use in any situation where you are testing code for the creation of files and directories. All such tests should take place in a temporary directory functioning as a sandbox, and that temporary directory and its contents should be removed when the test has been completed.
My only quibble with File::Temp is that, having used the object-oriented interface and gotten accustomed to having my tempfiles be deleted when the object goes out of scope, I long for the same facility with respect to tempdirs. As of v0.16, 'tempdir' is available only through the functional interface and you must explicitly call CLEANUP => 1 to get the tempdirs so created deleted at the end of the *program*. I would love to have a function/method that automatically deletes tempdirs at the end of their *enclosing scope/block*. This would, for example, enable me to create a tempdir within a block, test for its existence, have the tempdir deleted automatically when the block is closed, then test again for its non-existence.
This wish aside, kudos to Tim Jenness for both writing File::Temp and, even more importantly, maintaining it over the years.
I'll say up front that one of two of the interface decisions in File::Temp bug me. Some things are given confusingly-similar names, and then there's CLEANUP => 1. In the end, though, these minor quibbles are overshadowed by the incredible usefulness of self-destroying files and directories. My test scripts abound with File::Temp use; make a directory, go hog wild making files in it, and when you're done it goes away. Dump logs into tmpfiles for analysis. Later on they're gone. Totally freaking awesome.
A great module for regular use - if you need to save a temporary file, use File::Temp. It saves a lot of time and effort, and tries to make sure the temporary file is as safe as possible.
File::Temp is temporary file handling done right. It takes care of all the annoying bits that make dealing with temporary files a hassle. In particular, I find temporary files indispensable for atomic writing to data files that might be opened by other (less careful) processes.
The interface of File::Temp is a bit odd. KEY => value pairs in all caps don't feel natural to me and a couple of for historic reasons differently named functions doing basically the same thing aren't at the height of interfaces in my opinion.
I would be able to do the temporary file handling without the module pretty well, but it would cost me significantly more thought. But just a few years ago, I mightn't have known about all the weird things that can happen to a simple-minded approach. So: (File::Temp)++
This module seems to do what it claims: create temporary directories and files and clean them up when the program is done, without having to do any book-keeping.
It's very easy to use.
Nice and easy to use. I love the fact that it supports any implementation and any programming style you might fancy. Only drawback is that the docs look a bit "scary" at first contact. Maybe include more basic examples at the top like:
With no parameters. Simple. Vanilla. No Sprinkles, whipped cream or chocolate syrup.