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

Re^3: Generate a unique ID

by zwon (Monsignor)
on Nov 16, 2010 at 00:44 UTC ( #871613=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Generate a unique ID
in thread Generate a unique ID

So far it looks for me like you trying to reinvent the wheel. You need to create directory with unique name?

$dir = File::Temp->newdir;

That's it. If you want, you can specify template for the directory name which will include timestamp or whatever you want. If it return failure, it's for some other reason.


Comment on Re^3: Generate a unique ID
Download Code
Replies are listed 'Best First'.
Re^4: Generate a unique ID
by BrowserUk (Pope) on Nov 16, 2010 at 06:51 UTC

    I started out looking to create unique filenames, that during a later stage of the processing, I could differentiate from those created by other runs of the code, via globbing, .

    Once sundialsvc4 suggested using a directory--which hadn't crossed my mind earlier--using a temporary directory and creating all my files within it make perfect sense.

    I'm not sure that module buy me anything useful over something like:

    my $path = $ENV{ TMP }; my $dir = 'temp' . join'', map{ ('A'..'Z')[rand 26] } 1 .. 4; ++$dir until mkdir $path . $dir or $! != 17 and die "$path$dir : $!;

    But I guess that depends whether this code will ever make it to another platform. I don't see that ever happening.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2015-07-29 23:14 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 (269 votes), past polls