Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Time in Milliseconds or NanoSeconds

by DrAxeman (Beadle)
on Aug 12, 2005 at 01:24 UTC ( #483163=note: print w/ replies, xml ) Need Help??


in reply to Time in Milliseconds or NanoSeconds

Maybe this is an over-simplified look at it, but why not simply use rand() to append a new value to the file?

Or is there a chance that you'd get still get duplicates? If not, this would be a very simple solution with little overhead.


Comment on Re: Time in Milliseconds or NanoSeconds
Re^2: Time in Milliseconds or NanoSeconds
by thor (Priest) on Aug 12, 2005 at 11:21 UTC
    Or is there a chance that you'd get still get duplicates?
    Bingo. For truly random numbers, it's not unreasonable to get the same number 50 times in a row. Moreover, when you ask a computer for a random number, one of two things happens. Maybe it uses a pseudo-random number generator (PRNG), which has an inherent (albeit large) cycle, to get it. Or, maybe it has some way to get truly random numbers. But that falls into the first trap. To me, when someone wants uniqueness, UUID comes to mind. It's already been mentioned by another poster in this thread.

    HTH,
    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      Excellent point.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-04-23 19:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (554 votes), past polls