23 Feb 2000 17:10:33 UTC
- Distribution: File-MkTemp
- Module version: 1.0.6
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (1896 / 1 / 0)
- KwaliteeBus factor: 0
- License: unknown
- Activity24 month
- Download (4.99KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionTGUMMELS Travis Gummels
File::MkTemp - Make temporary filename from template
use File::MkTemp; mktemp(tempXXXXXX,[dir]); $string = mktemp(tempXXXXXX,[dir]); open(F,$string); mkstemp(tempXXXXXX,dir); $fh = mkstemp(tempXXXXXX,dir); print $fh "stuff"; $fh->close; mkstempt(tempXXXXXX,dir); ($fh,$template) = mkstempt(tempXXXXXX,dir); print $fh "stuff"; $fh->close; print "Template is: $template\n";
The MkTemp module provides three functions mktemp() mkstemp() and mkstempt().
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.
The function mkstempt() does the same as mkstemp() except it returns the name of the template in addition to the file handle.
File::MkTemp was written by Travis Gummels. Please send bug reports and or comments to: firstname.lastname@example.org
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 and notify the author.