mktemp#

Fill in the trailing Xs of a template and return the resulting filename - does not create the file.

תקציר#

my $name = mktemp('/tmp/dataXXXXXX');

מה מוחזר#

A candidate filename string with random characters substituted for the trailing Xs. No file is created; the caller must open it themselves and accept the race between naming and opening.

דוגמאות#

use File::Temp qw/ mktemp /;
my $name = mktemp('/var/tmp/snapXXXXXXXX');

מקרי קצה#

  • Template with fewer than four trailing Xs: croaks.

  • Wrong arg count: croaks with a usage message.

  • Unsafe against racing attackers - prefer tempfile.

הבדלים מן ה-upstream#

Fully compatible with upstream File::Temp 0.2312.

ראו גם#

  • tempfile - race-safe replacement.

  • mkstemp - same idea, but also creates and opens the file.

  • tempnam - dir + prefix variant.