Well, you certainly have created quite a rant here.

But if you are looking for unique filenames, have you tried this?

use Time::HiRes qw (time);
printf("%0.6f\.txt",time);

Just a thought.

It's also guaranteed no dupes for about 20 years, unless you want lots
of file names in a VERY VERY short amount of time.  And even then, you
could just wait a nanosecond or two for a non-dupe filename to appear...
LOL

Cheers!

Steven 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Chris
Sent: Wednesday, November 30, 2005 9:13 AM
To: perl-win32-users
Subject: RE: rand() not so random

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.


------------------------------

I've also had this problem when generating random tokens. My solution
was to use the date & time along with a random string.

E.g. 20051130_110725_A93hQ4d1.txt


- Chris


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



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

Reply via email to