tmpfile#
POSIX-style tmpfile — open an anonymous temporary file and return the filehandle. The file is unlinked immediately.
Synopsis#
my $fh = tmpfile();
print $fh "scratch\n";
seek $fh, 0, 0;
What you get back#
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.
Examples#
my $fh = tmpfile();
print $fh "line 1\n";
seek $fh, 0, 0;
my $line = <$fh>; # "line 1\n"
Edge cases#
On filesystems that refuse to unlink open files the file stays on disk until
$fhis closed.
Differences from upstream#
Fully compatible with upstream File::Temp 0.2312.
See also#
tempfile— gives you both filehandle and filename.tmpnam— returns only a name (or($fh, $name)in list context).