Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: gernerating unique string

by dga (Hermit)
on Sep 19, 2001 at 20:20 UTC ( #113392=note: print w/replies, xml ) Need Help??


in reply to gernerating unique string

Even if its a 'low volume' form you still may get 2 people hitting it at the same time even if you only get 3 hits on a given day.

One easy one if you aren't worried about people making these up to circumvent the reason you are using a random value in the first place would be to use pid and Time::HiRes;

use strict; use Time::HiRes qw(time); my $uniq_value="$$" . time;

$uniq_value will be something like 153331000916182.10074

This will be unique since the same CGI can't do 2 of these without that last digit stepping with current CPU and network speeds and each process has its own pid so even 2 at the same time will be unique.

The number could be predicted in advance since its totally linear and not random at all.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2022-08-18 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?