mkdtemp#

Create a directory from a template and return its path.

Synopsis#

my $dir = mkdtemp('/tmp/buildXXXXXX');

What you get back#

The pathname of the directory created with mode 0700. The directory is not registered for cleanup — it remains until the caller removes it or arranges for cleanup themselves.

Examples#

use File::Temp qw/ mkdtemp /;
my $dir = mkdtemp('/var/tmp/stageXXXXXX');

## caller owns $dir; remove with rmtree / File::Path

Edge cases#

  • Template with fewer than four trailing Xs: croaks.

  • Wrong arg count: croaks with a usage message.

Differences from upstream#

Fully compatible with upstream File::Temp 0.2312.

See also#

  • tempdir — higher-level variant accepting CLEANUP => 1.

  • File::Temp->newdir — OO form that removes the tree automatically.

  • mkstemp — file counterpart.