tempdir#
Create a uniquely named temporary directory and return its path.
תקציר#
my $dir = tempdir();
my $dir = tempdir($template, DIR => $parent, CLEANUP => 1);
my $dir = tempdir(CLEANUP => 1);
מה מוחזר#
A plain string - the full path of the new directory, created with mode 0700. The directory is not removed automatically unless CLEANUP => 1 is passed.
Options#
DIR => $parent- parent directory for the new temp dir.TMPDIR => 1- place the directory under the system temp dir.TEMPLATE => $t- template with at least four trailingX.CLEANUP => 1- remove the directory (and its contents) at exit.
דוגמאות#
use File::Temp qw/ tempdir /;
my $dir = tempdir(CLEANUP => 1);
open my $fh, '>', "$dir/notes.txt";
## $dir and its contents are removed at process exit
my $dir = tempdir('buildXXXXXX', DIR => '/var/tmp');
## directory remains after the process exits (no CLEANUP)
מקרי קצה#
Called as
File::Temp->tempdir(method form): croaks.Parent directory missing or not a directory: croaks.
Without
CLEANUP, the directory persists - the caller owns it.
הבדלים מן ה-upstream#
Fully compatible with upstream File::Temp 0.2312.
ראו גם#
File::Temp->newdir- OO form whose object removes the tree on destruction.mkdtemp- template-only low-level variant.tempfile- file counterpart with the same option vocabulary.cleanup- trigger registered cleanups manually.