Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Use time() to create unique ID

by adrianh (Chancellor)
on Sep 16, 2003 at 16:50 UTC ( [id://291877]=note: print w/replies, xml ) Need Help??


in reply to Use time() to create unique ID

Personally I would just use Data::UUID instead.

Replies are listed 'Best First'.
Re: Re: Use time() to create unique ID
by smellysocks (Beadle) on Sep 16, 2003 at 18:22 UTC

    Using time or even time::Hires does not Using time or even time::Hires does not guarantee you uniqueness in any manner. How do you know your application will not be run more then once concurrently?

    BTW are you using human time or ctime? Don't forget about day light savings time, clock adjustments from ntp, server moves to a different timezone, etc.,etc.,etc.

    Clocks change.

    Are you sure? What about when you borrow your code and reuse it on a busier site and forget about that hidden feature?

    I would have to vote for the either the use of rand, or the use of Data::UUID (see link above). I never played with Data::UUID, but it looks like something to add to the list to check out.

    As cowdawg stated the probability of a collistion is low, and you need to VERIFY that the number is unique.

    BTW a name collistion is generally always possible no matter what you do.

    Heck, if you are convienced that you MUST use time(), or a varient, append a random number to the "time,"

    My $1.50,

    - smellysocks

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-26 08:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found