Arch::TempFiles(3pm)
π Arch::TempFiles π
okay bestie, listen up β this is Arch::TempFiles, part of the User Contributed Perl Documentation collection, and she's here to help you manage your temporary files and dirs. yes, those files. the little gremlins you leave everywhere and then forget about. she's got you. π
β¨ NAME β¨
Arch::TempFiles β help to manage temporary files/dirs π«Ά
β¨ SYNOPSIS β¨
okay so here's the vibe, function-style first:
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");
and now the object-oriented glow-up, she's giving main character energy:
use Arch::TempFiles;
my $tmp = new Arch::TempFiles;
$tmp->root($tmp->dir);
my $file_name = $tmp->name;
open OUT, ">$file_name";
close OUT;
β¨ DESCRIPTION β¨
so this module deals with temporary file names, periodt. it's similar to File::Temp, but simplier and more focused β and also, File::Temp is relatively new and was not shipped with older perl versions, so like... she wasn't even available back in the day. tragic. π
both the function interface and the object oriented interface are supported. pick your fighter, queen. π
β¨ FUNCTIONS/METHODS β¨
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.
πΈ temp_root [dir] / $tmp->root [dir]
change or return the root of the temporary files and dirs. the default is either $ENV{TMP_DIR} or "/tmp". so like, if you've set the env var, she'll respect it. otherwise, /tmp it is. π
πΈ temp_name [label] / $tmp->name [label]
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. β¨
β οΈ okay this part is IMPORTANT bestie, no cap: 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. race condition behavior, we hate to see it, but we must respect it. π
πΈ temp_file_name [label] / $tmp->file_name [label]
like temp_name, but stores the name in the file list that will be removed on the end (on object destruction). so she remembers, so you don't have to. π
πΈ temp_dir_name [label] / $tmp->dir_name [label]
like temp_name, but stores the name in the dir list that will be removed on the end (on object destruction). same energy, different list. π
πΈ temp_file [label] / $tmp->file [label]
like temp_file_name, but also creates the file. boom, done, file exists. π¦
πΈ temp_dir [label] / $tmp->dir [label]
like temp_dir_name, but also creates the dir. iconic behavior honestly. π
β¨ BUGS β¨
awaiting for your reports. π
(no like literally, she's waiting. drop them in, bestie, she's ready. π)
β¨ AUTHORS β¨
Mikhael Goikhman (migo@homemail.com--Perl-GPL/arch-perl--devel). π
β¨ SEE ALSO β¨
for a different interface, see File::Temp. π
okay that's the whole page!! this was perl v5.20.2, dated 2005-04-22, and she ate, no crumbs. slay, go clean up your temp files, mwah π β¨π
π¦ where this page comes from
- ubuntu jammy: libarch-perl 0.5.2-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms