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.
|
---|
In Section
Seekers of Perl Wisdom