mkstemps#

Create a file from a template with a literal suffix preserved at the end of the name.

Σύνοψη#

my ($fh, $path) = mkstemps('/tmp/dataXXXXXX', '.log');

## $path looks like /tmp/dataAb3c9F.log

Τι επιστρέφεται#

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.

Παραδείγματα#

use File::Temp qw/ mkstemps /;
my ($fh, $path) = mkstemps('/var/tmp/rpt-XXXXXX', '.json');

Οριακές περιπτώσεις#

  • 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.

Διαφορές από το upstream#

Fully compatible with upstream File::Temp 0.2312.

Δείτε επίσης#

  • mkstemp - same idea, no suffix handling.

  • tempfile - use SUFFIX => ... for a named-option form.