Initializing Perl's rand
Kim Holburn
kim.holburn at anu.edu.au
Tue Jun 25 00:23:54 EST 2002
At 11:57 PM +1000 2002/06/24, Michael James wrote:
>Can anyone help me out here.
>
>I am using rand in perl.
>The book says it should get initialized (call srand) on the first invocation.
>Supposed to be true on any version 5.004 or after, and I'm using 5.6.1
>
>But my script just took the exact same random walk 3 times running,
> and I'm suspicious. I need runs to differ.
You could try the entropy gathering daemon egd : http://egd.sourceforge.net/
It's written in perl and I think you can cpan it and maybe it doesn't need to compile anything (so you can use it with pre osx).
I seem to remember the cookbook had some examples of srand stuff but i think it might have depended on some unix stuff.
>
>Does perl initialize to the same seed each run?
>How can I make it get a different seed each run?
>
>The script is going to have to run under MacPerl
> so I don't want to to to unixy a thing and read /dev/urandom
>
>For now I'm calling srand with
> the process id raised to the number of seconds
> it took for the user to answer the starting questions.
>
>Any better ideas?
>
>TIA,
>michaelj
>--
>A right not exercised is a privilege
>a privilege not exercised is illegal.
>
>Michael James michael at james.st
>8 Brennan St Phone: +61 2 6247 2556
>Hackett, ACT 2602 Mobile: +61 4 1747 4065
>AUSTRALIA Fax: +61 2 6278 0011
--
--
Kim Holburn Network Consultant P: +61 2 61258620 M: +61 0417820641
Email: kim.holburn at anu.edu.au - PGP Public Key on request
Life is complex - It has real and imaginary parts.
Andrea Leistra (rec.arts.sf.written.Robert-jordan)
More information about the linux
mailing list