OpenBSD::MkTemp(3p) Perl Programmers Reference Guide OpenBSD::MkTemp(3p)

OpenBSD::MkTemp - Perl access to mkstemps() and mkdtemp()

  use OpenBSD::MkTemp;
  my($fh, $file) = mkstemp("/tmp/fooXXXXXXXXXX");
  use OpenBSD::MkTemp qw(mkdtemp mkstemps);
  my $dir_name = mkdtemp("/tmp/dirXXXXXXXXXX");
  my ($fh, $file) = mkstemps("/tmp/fileXXXXXXXXXX", ".tmp");

This module provides routines for creating files and directories with guaranteed unique names, using the C mkstemps() and mkdtemp() routines.

mkstemp() and mkstemps() must be called with a template argument that is writable, so that they can update it with the path of the generated file. They return normal perl IO handles.

mkdtemp() simply takes the template and returns the path of the newly created directory.


  $fh = mkstemp($template)

  $fh = mkstemps($template, $suffix_len)
  $dir = mkdtemp($template);


Philip Guenther, <>

Copyright (C) 2010 by Philip Guenther

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.2 or, at your option, any later version of Perl 5 you may have available.

2016-05-08 perl v5.36.3