Initializing Perl's rand

Michael James michael at
Mon Jun 24 23:57:23 EST 2002

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?

A right not exercised is a privilege
a privilege not exercised is illegal.

Michael James			michael at
8 Brennan St			Phone: +61 2 6247 2556
Hackett, ACT 2602		Mobile: +61 4 1747 4065
AUSTRALIA			Fax: +61 2 6278 0011

More information about the linux mailing list