in reply to Re: rand() function on Windows systems
in thread rand() function on Windows systems

>  to give you always the same sequence of numbers.

But this IS documented behavior, see srand

The point is rather that you can't guarantee the same sequence for newer Perl versions because this would inhibit any progress.

Progress like being OS independent.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

  • Comment on Re^2: rand() function on Windows systems

Replies are listed 'Best First'.
Re^3: rand() function on Windows systems
by Laurent_R (Canon) on Dec 30, 2016 at 21:49 UTC
    But this IS documented behavior, see srand
    Yes, Rolf, agreed. I know that if you initialize srand with a specific number, you'll be able to get repeatedly the same sequence from rand if you run it several times on the same machine with the same Perl version. This is not specific to perl, many programming languages have the same feature. And this is useful especially for some testing purposes (e.g. to be able to test the same conditions several times).

    But I said: "you should probably not try to rely on a random number generator to give you always the same sequence of numbers." The word always is important in what I meant. One should not expect the same sequence forever.

    And the possible solution I suggested relies on that: if you need the same sequence of pseudo-random integers with different Perl versions and platforms, for whatever reason,, then store that sequence somewhere and re-use it.