in reply to Legacy code uses "srand()" .. how to avoid losing entropy?
Sure, you get a different stream of random numbers, but it's just as random as the one you had before. Heck, you could even make it a function:srand($known_thing); # code relying on $known_thing srand(0);
sub with_srand { srand(shift); $_[0]->(@_[1..$#_]); srand(); } # later with_srand $known_thing, sub { ... }, args...;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Legacy code uses "srand()" .. how to avoid losing entropy?
by locked_user sundialsvc4 (Abbot) on May 04, 2011 at 12:30 UTC |