tmpnam#
POSIX-style tmpnam - in scalar context a candidate filename in the system temp directory; in list context a created file with its filehandle.
תקציר#
my $name = tmpnam(); # scalar: just a name
my ($fh, $name) = tmpnam(); # list: creates the file
מה מוחזר#
In scalar context a filename string in the system temp directory that does not exist at the moment of the call - there is still a race between picking it and opening it, so prefer tempfile. In list context, a freshly created file is returned along with its filehandle.
דוגמאות#
use File::Temp qw/ tmpnam /;
my ($fh, $name) = tmpnam(); # race-free file creation
מקרי קצה#
Scalar context does not create a file - callers must open the name themselves and accept the race.
הבדלים מן ה-upstream#
Fully compatible with upstream File::Temp 0.2312.
ראו גם#
tempfile- the recommended race-safe replacement.tmpfile- file is opened and unlinked immediately.mkstemp- template-based creation.