mkstemps#
Create a file from a template with a literal suffix preserved at the end of the name.
Synopsis#
my ($fh, $path) = mkstemps('/tmp/dataXXXXXX', '.log');
## $path looks like /tmp/dataAb3c9F.log
What you get back#
In list context ($fh, $path); in scalar context just the
filehandle. The suffix is appended to the template before
filling, and the Xs before it are the ones replaced.
Examples#
use File::Temp qw/ mkstemps /;
my ($fh, $path) = mkstemps('/var/tmp/rpt-XXXXXX', '.json');
Edge cases#
The suffix is a literal string, not a length count.
Template with fewer than four trailing
Xs before the suffix: croaks.Wrong arg count: croaks with a usage message.
Differences from upstream#
Fully compatible with upstream File::Temp 0.2312.
See also#
mkstemp— same idea, no suffix handling.tempfile— useSUFFIX => ...for a named-option form.