tempnam#

Return a candidate filename under $dir starting with $prefix - does not create the file.

תקציר#

my $name = tempnam('/var/tmp', 'cache_');

מה מוחזר#

A full path string "$dir/${prefix}XXXXXXXX" with the Xs replaced by random characters. The caller is responsible for opening the file, and there is a race between name selection and open.

דוגמאות#

use File::Temp qw/ tempnam /;
my $name = tempnam('/tmp', 'sess-');
open my $fh, '>', $name or die;

מקרי קצה#

  • Wrong arg count: croaks with a usage message.

  • Like mktemp, unsafe against attackers - prefer tempfile.

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

Fully compatible with upstream File::Temp 0.2312.

ראו גם#

  • tempfile - race-safe replacement returning both filehandle and name.

  • mktemp - similar idea with a caller-supplied template.