Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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 studying the Monastery: (10)
As of 2015-07-29 07:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls