Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: gernerating unique string

by dga (Hermit)
on Sep 19, 2001 at 20:20 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2024-04-25 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found