Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: "unique" filename?

by quidity (Pilgrim)
on Dec 03, 2000 at 22:22 UTC ( #44688=note: print w/replies, xml ) Need Help??


in reply to "unique" filename?

The module File::MkTemp seems to be what you want:

use File::MkTemp; $dir = '.'; # directory to create file in $string = mktemp('tempXXXXXX',$dir); open(F,$string);

Will return a unique file name, you can also have it return a unique file handle so that there is no chance of opening an identical file in two instances of your script:

use File::MkTemp; $dir = '.'; # directory to create file in $fh = mkstemp('tempXXXXXX',$dir); print $fh "stuff"; $fh->close;

You can add more 'X's, but you need at least six.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://44688]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2016-12-11 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (168 votes). Check out past polls.