The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

File::MkTempO - Make temporary filename from template

SYNOPSIS

  use File::MkTempO;

  $object = new File::MkTempO('tempXXXXXX','dir');

  $string = $object->mktemp;
  open(F,$string);
  close(<F>);


  $fh = $object->mkstemp;
  print $fh "stuff";
  $fh->close;

  print "template stored in the object: $object->template\n";
  print "directory stored in the object: $object->dir\n";
  print "file handle in scalar form: $object->fhtmpl\n";
  print "fh and the directory in scalar form: $object->fhdirtmpl\n";

DESCRIPTION

The MkTempO module provides the following functions:

  new()      - for creation of the object.
  mktemp()   - for creation of a unique string based on the template
  mkstemp()  - for creation of a unique file handle opened in the 
               directory specified during creation of the object.
  template() - for returning the template stored in the object.
  dir()      - for returning the directory stored in the object.
  fhtmpl()   - for returning the file handle in scalar form.
  fhdirtmpl()- for returning the file handle and the directory its in.

The function mktemp() returns a unique string based upon the template. The template must contain at least six trailing Xs. The Xs are replaced by a unique string and the template is returned. The unique string is made from picking random elements out of a 52 alpha character array ([a-z][A-Z]). A directory can be specified in which to test for duplicates of the string.

The function mkstemp() does the same as mktemp() except it returns an open file handle. This prevents any possibility of opening up an identical file. The function requires that the directory be specified when creating the object with the new function.

AUTHOR

File::MkTemp was written by Travis Gummels. Please send bug reports and or comments to: travis@gummels.com

COPYRIGHT

Copyright 1999|2000 Travis Gummels. All rights reserved. This may be used and modified however you want. If you redistribute after making modifications please note modifications you made somewhere in the distribution.