http://qs321.pair.com?node_id=272972


in reply to Can I seed srand() with results from rand()?

The process starts with a random seed that I provide, so that I can reproduce interesting results later.

The code you provided will make it hard for you to reproduce the results later.

The only thing that is predictable about rand() is that given the exact same input to srand(), you will get the exact same outputs from rand() every time you do it.

So:
srand(42) -> 78, 102, 4, 19, ...
srand(55) -> 8, 2, 66, 243, ...

There isn't anything wrong with calling srand() more than once, except that doing so will not make the output more random, it may even make it less random.

To reproduce the same outputs from rand(), you will have to call srand() with the same inputs in the same order every time, so this is a new part of state that you must save. On top of that, if the implementation of rand() changes in different versions of perl, you will not reproduce the same results on different versions.