in reply to Re: srand producing the same sequence of random numbers
in thread srand producing the same sequence of random numbers
As far as I am aware, this behavior is the only (practical) purpose for the existence of srand().
Certain statistical tests require that a (pseudo-)random sample be taken from a population, then at some future point, another sample is taken which examines the same elements. One way to do this, of course, would be to store the random sequence, but that can be memory-intensive. Hence, srand(). First, you obtain a random number in the usual way. Then, you use srand() to establish that (randomly chosen) number as the new “seed.” Now, you can easily produce an arbitrarily long pseudo-random number sequence that can be repeated perfectly, just by re-assigning the seed.
Because this is Perl, “TMTOWTDI.™” Perl has many pseudo-random number generator packages available.