Arch::TempFiles - help to manage temporary files/dirs
use Arch::TempFiles qw(temp_file_name temp_file temp_dir); # all will be removed automatically on the script completion my $file_name1 = temp_file(); my $file_name2 = temp_file_name("status"); my $dir_name = temp_dir("arch-tree"); use Arch::TempFiles; my $tmp = new Arch::TempFiles; $tmp->root($tmp->dir); my $file_name = $tmp->name; open OUT, ">$file_name"; close OUT;
This module deals with temporary file names. It is similar to File::Temp, but simplier and more focused. Also, File::Temp is relatively new and was not shipped with older perl versions.
Both function interface and object oriented interface are supported.
The following functions are available:
temp_root, temp_name, temp_file_name, temp_dir_name, temp_file, temp_dir.
The corresponding class methods are available too:
root, name, file_name, dir_name, file, dir.
Change or return the root of the temporary files and dirs. The default is either $ENV{TMP_DIR} or "/tmp".
Return the unused temporary file name. The default file name is "/tmp/,,arch-XXXXXX" where XXXXXX is a random number. To change this name use temp_root and/or provide label that replaces "arch".
temp_root
Please note, that the operation of acquiring the file name using this function/method and actual creating of this file is not atomic. So you may need to call this method again if the creation is failed, for example if some other process created the same file in the middle.
Like temp_name, but stores the name in the file list that will be removed on the end (on object destruction).
temp_name
Like temp_name, but stores the name in the dir list that will be removed on the end (on object destruction).
Like temp_file_name, but also creates the file.
temp_file_name
Like temp_dir_name, but also creates the dir.
temp_dir_name
Awaiting for your reports.
Mikhael Goikhman (migo@homemail.com--Perl-GPL/arch-perl--devel).
For a different interface, see File::Temp.
To install Arch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Arch
CPAN shell
perl -MCPAN -e shell install Arch
For more information on module installation, please visit the detailed CPAN module installation guide.