*BSD News Article 55929


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!newsroom.utas.edu.au!dslip3.cc.utas.edu.au!user
From: andrew@hobart.tased.edu.au (Andrew)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Random in Perl
Date: Mon, 04 Dec 1995 02:01:54 +1100
Organization: University of Tasmania, Australia.
Lines: 28
Message-ID: <andrew-0412950201540001@dslip3.cc.utas.edu.au>
NNTP-Posting-Host: dslip3.cc.utas.edu.au

Hi,

I have a CGI script written in perl. It needs one random number each
execution but every time it calls rand it gets the same number. This isn't
quite true it changes every 6 or 7 calls before going back to the original
value. Yes - I had first called srand;

Someone in comp.lang.perl suggested srand(time^$$);
This is better as now the number changes every 3 or 4 calls. This is still
not quite random enough for me however :(

If I write a script to output _multiple_ random numbers (it graphs them to
:) they appear to be random.

Has anybody else experienced this? Any ideas on how to fix it? I'm using
2.0.5 on a 486SX. I'm planning to upgrade to 2.1 (and a HD that dosn't
overheat and take the entire filsesytem with it) tommorrow and so mail to
me might bounce for a while. I will however keep reading this group from
my mac.

Thanks for reading,

Andrew

-- 
--
Life is very short, and there's no time
For fussing and fighting, my friend.   WCWIO??TB