Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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.


Comment on Re: "unique" filename?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://44688]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2014-09-02 22:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (32 votes), past polls