Initializing Perl's rand

Patrick Cole z at
Tue Jun 25 02:08:18 EST 2002

Mon, Jun 24, 2002 at 11:57:23PM +1000, 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.
> 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?

More information about the linux mailing list