Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Time in Milliseconds or NanoSeconds

by DrAxeman (Scribe)
on Aug 12, 2005 at 01:24 UTC ( [id://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

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://483163]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-25 20:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found