tmpfile#

POSIX-style tmpfile - open an anonymous temporary file and return the filehandle. The file is unlinked immediately.

תקציר#

my $fh = tmpfile();
print $fh "scratch\n";
seek $fh, 0, 0;

מה מוחזר#

An open read/write filehandle reference. There is no filename to hand out: the file is removed from the directory immediately after opening and exists only as long as $fh is open.

דוגמאות#

my $fh = tmpfile();
print $fh "line 1\n";
seek $fh, 0, 0;
my $line = <$fh>;                           # "line 1\n"

מקרי קצה#

  • On filesystems that refuse to unlink open files the file stays on disk until $fh is closed.

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

Fully compatible with upstream File::Temp 0.2312.

ראו גם#

  • tempfile - gives you both filehandle and filename.

  • tmpnam - returns only a name (or ($fh, $name) in list context).