*BSD News Article 56517


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!nntp.coast.net!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!jussieu.fr!math.ohio-state.edu!howland.reston.ans.net!newsfeed.internetmci.com!info.ucla.edu!library.ucla.edu!agate!tfs.com!mailhub.tfs.com!julian
From: julian@mailhub.tfs.com (Julian Elischer)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Random in Perl
Date: 3 Dec 1995 23:54:41 GMT
Organization: TRW Financial Systems, Oakland, CA
Lines: 18
Message-ID: <49tdc1$9ct@times.tfs.com>
References: <andrew-0412950201540001@dslip3.cc.utas.edu.au>
NNTP-Posting-Host: mailhub.tfs.com

In article <andrew-0412950201540001@dslip3.cc.utas.edu.au>,
Andrew <andrew@hobart.tased.edu.au> wrote:
: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;

in -current there is a /dev/random --produces REALLY random stream of bits

:
: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 :(
add your last random number as well?
:
:If I write a script to output _multiple_ random numbers (it graphs them to
::) they appear to be random.
: