in reply to how portable is the random number generator?
Why? It's a random number generator.
If this is for testing, then mock the rand function (or wrap it in a function for easier mocking).
If you need a reliable sequence of pseudo-random numbers for whatever reason, then use a fixed PRNG implementation (search CPAN for PRNG and Math::Random). There are even ones simple enough that you can implement them yourself, like say Xorshift (though there's a module on CPAN for that too, of course).
If it's just for a JAPH, then the perldelta for 5.20 says "Perl now uses its own internal drand48() implementation on all platforms" (also mentioned in the rand doc), with no mention of the PRNG in the deltas since then - but no guarantees that this won't change in the future, since again, it's a random number generator.
But at least that answers your question: Your JAPH should produce the same output on Perl 5.20 though at least the current 5.42 on all platforms.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how portable is the random number generator?
by haukex (Archbishop) on Jan 24, 2026 at 15:40 UTC |