File::Fu::File::Temp3pm
Temporary files
Usage
use File::Fu;my $handle = File::Fu->temp_file;
new
The directory argument is required, followed by an optional template argument and/or flags. The template may contain some number of 'X' characters. If it does not, ten of them will be appended.
my $handle = File::Fu::File::Temp->new($dir, 'foo');my $file = $handle->name;
By default, the file will be deleted when the handle goes out of scope. Optionally, it may be deleted immediately after creation or just not deleted.
my $handle = File::Fu::File::Temp->new($dir, 'foo', -secure);my $handle = File::Fu::File::Temp->new($dir, -noclean);# also $handle->noclean;
- -secure
-
Delete the named file (if the OS supports it) immediately after opening.
Calling
name()on this sort of handle throws an error.
- -nocleanup
-
Don't attempt to remove the file when the
$handlegoes out of scope.
name
my $file_obj = $handle->name;
nocleanup
Disable autocleanup.
$handle->nocleanup;
write
Write @content to the tempfile and close it.
$handle = $handle->write(@content);
do
Execute subref with $handle as $_. If you chain this with the constructor, the destructor cleanup will happen immediately after sub has returned.
my @x = $handle->do(sub {something($_->name); ...});
Destroy
Called automatically when the handle goes out of scope.
$handle->DESTROY;
XXX
Constant representing a chunk of X characters.
No warranty
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.
Releases
8 releases since Debian 6.0 (Squeeze); the text changed 3 times.