in reply to srand producing the same sequence of random numbers

AFAIK, the only purpose for srand() is to be able to obtain a repeatable set of “random” numbers, e.g. for certain esoteric statistical sampling purposes or some similar special purpose. The intended behavior is exactly what you saw:   after re-seeding, the pseudo-random sequence repeats.

The random number generator does not need to be re-seeded, ever, in normal practice.

The standard random number generator is not suitable for cryptographic purposes.

Replies are listed 'Best First'.
Re^2: srand producing the same sequence of random numbers
by ikegami (Patriarch) on Oct 12, 2010 at 06:43 UTC

    The random number generator does not need to be re-seeded, ever, in normal practice.

    Every interpreter needs to be seeded. Perl will do that automatically, except when the interpreter is cloned by fork.

    $ perl -e' rand(10); if (my $pid = fork()) { waitpid($pid, 0); } local ($,, $\) = (", ", "\n"); print map int(rand(10)), 1..10; ' 8, 3, 9, 8, 8, 2, 3, 8, 4, 8 8, 3, 9, 8, 8, 2, 3, 8, 4, 8