Simple implementation of File::Temp for creating temporary files
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/File close handle before unlink file; and close all handles in END Oct 31, 2017
t Fix GC tests Jul 27, 2017
.travis.yml update Travis file Jun 19, 2017
META6.json update license and version Jul 28, 2017

Build status




# Generate a temp file in a temp dir
my ($filename,$filehandle) = tempfile;

# specify a template for the filename
#  * are replaced with random characters
my ($filename,$filehandle) = tempfile("******");

# Automatically unlink files at DESTROY (this is the default)
my ($filename,$filehandle) = tempfile("******", :unlink);

# Specify the directory where the tempfile will be created
my ($filename,$filehandle) = tempfile(:tempdir("/path/to/my/dir"));

# don't unlink this one
my ($filename,$filehandle) = tempfile(:tempdir('.'), :!unlink);

# specify a prefix and suffix for the filename
my ($filename,$filehandle) = tempfile(:prefix('foo'), :suffix(".txt"));


This module exports two routines:

  • tempfile creates a temporary file and returns a filehandle to that file opened for writing and the filename of that temporary file

  • tempdir creates a temporary directory and returns the directory name.


Jonathan Scott Duff