mp has asked for the wisdom of the Perl Monks concerning the following question:

For use in a shuffling algorithm, I need to be able to generate repeatable pseudo random sequences of integers in a range 1-N, such that given the same (integer) seed, the same sequence will always be produced.

I currently do:

srand($seed) ... $j = int rand ($n + 1); ...
inside a Fisher-Yates shuffle algorithm. This works, but also "taints" the random number generator by setting the seed to a deterministic value. Since this code runs under mod_perl, it is possible that later code will require a random number that is not so deterministically chosen, so I would like to avoid leaving the seed set to a deterministic value.

Is there a way to find out what the current seed is, so that I can restore it after generating the pseudo random sequence? Would calling srand() with no arguments after the deterministic sequence generation is complete be adequate, with regard to what perldoc -f srand says?

     Do not call "srand" multiple times in your program
     unless you know exactly what you're doing and why
     you're doing it.  The point of the function is to
     "seed" the "rand" function so that "rand" can pro­
     duce a different sequence each time you run your
     program.  Just do it once at the top of your pro­
     gram, or you won't get random numbers out of