Which I believe is what you’re looking for.I don't think so. Suppose he'd captured the seed, then what? This is certainly not what he want:
Now $random1 and $random2 are the same.sub func() { srand $CONSTANT; ... do stuff using a known sequence ... } my $seed = srand; my $random1 = rand; func(); srand $seed; # Get back to "random" sequence again? my $random2 = rand;
You'd have to keep track of how many random numbers one has generated, and each time you'd call srand with the original seed again, you'd have to call rand that times, discarding the result before continuing.
In reply to Re^2: Legacy code uses "srand()" .. how to avoid losing entropy?
by JavaFan
in thread Legacy code uses "srand()" .. how to avoid losing entropy?
by locked_user sundialsvc4
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |