http://www.perlmonks.org?node_id=803632

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

I noticed something about the built-in random number generator.

I tried the following:
perl -le'$n=1000000;for(1..$n){$x=rand;$h{$x}++}@b=sort keys %h;$,="\t +";print $h{$b[$_]},$b[$_] for 1..$n;print STDERR scalar @b' > randoms +.txt

This code generates 1000000 random numbers, performs the equivalent of sort | uniq -c on them, prints the unique numbers (with their frequencies) into the file randoms.txt, and also prints how many unique random numbers were generated.

On linux (Perl 5.10.0 coming straight from the Ubuntu 9.04 repo) this prints 1000000, meaning that every random number generated was unique. This was expected.

However, on Windows (Perl 5.10.0, the latest Camelbox build) this prints 32768, meaning that only that many unique numbers were generated and there were many duplicates.

Why is the random number generator so crippled in that particular build? Or is this platform-specific?