--------8<-----------
Has anyone else noticed this?  And has anyone at ActiveState noticed it
and
if so is anything being done about it?  What I'm talking about is the
rand()
function that doesn't seem to be so random after all.  Atleast 4 times
now,
over a multi day period, it has spit out the exact same sequence of
numbers.
The script is a mod_perl app that uses rand to generate a random temp
file
name.  If the name already exists it tries again, using rand(), 10
times.
After that it dies.  Now, it seems that a random sequence will never
have
the same 10+ digit number twice except maybe sporadically at large
intervals.  This rand is acting like it is just regurgitating values
from a
list!  I put in a call to srand to reinitialize it but it's yet to be
seen
whether that will fix it.  Like on Monday it might give 1, 2, 3, 4 and
then
on Wednesday it might spit out 1, 2, 3, 4 again!  The app is not heavily
used.
--------8<-----------

Depends what youre after - Whats wrong with int(rand($$)), or even
int(rand(time)) for slightly higher magnitudes? Looking at your post
suggests you want much lower integers though.

my $random = $min + int rand($max - $min + 1); # always satisfies my
needs

Note that perlfaq4 dictates the use of srand for perl versions < 5.004 -
what's your perl version?

Googling for random noise number generators yielded
http://www.random.org which seems to be the acme for your suspicions.

Cheers,

Just in

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to