newdir#
Construct a File::Temp::Dir object wrapping a newly created temporary directory.
Σύνοψη#
my $dir = File::Temp->newdir;
my $dir = File::Temp->newdir('buildXXXXXX', DIR => '/var/tmp', CLEANUP => 0);
Τι επιστρέφεται#
A blessed File::Temp::Dir object. It stringifies to the directory path, and its destructor removes the directory tree when CLEANUP is true (the default) and the current process matches the creating pid.
Options#
Same as tempdir except CLEANUP defaults to true. The object records the creator pid so child processes do not accidentally delete a parent’s directory on exit.
Παραδείγματα#
my $dir = File::Temp->newdir;
open my $fh, '>', "$dir/scratch"; # $dir stringifies
## $dir and its contents are removed when $dir goes out of scope
my $dir = File::Temp->newdir(CLEANUP => 0); # keep the tree
Οριακές περιπτώσεις#
Forked children do not clean up the parent’s directory.
$File::Temp::KEEP_ALL = 1suppresses removal on destruction.
Διαφορές από το upstream#
Fully compatible with upstream File::Temp 0.2312.
Δείτε επίσης#
tempdir- functional counterpart returning a plain path string.dirname- method on the returned object returning the path.unlink_on_destroy- toggle cleanup on a per-object basis.File::Temp->new- file counterpart.