use warnings; use strict; use Win32::API; my $srand = Win32::API::More->new( 'msvcr100', 'void srand(unsigned int seed)' ) or die "Error: ".Win32::FormatMessage(Win32::GetLastError()); my $rand = Win32::API::More->new( 'msvcr100', 'int rand()' ) or die "Error: ".Win32::FormatMessage(Win32::GetLastError()); $srand->Call(0); print $rand->Call()/(1<<15), "\n"; # 0.00115966796875 #### sub winrand { use feature 'state'; state $r = 0; # seed $r = ( 214013*$r + 2531011 ) & 0xFFFFFFFF; return ($r>>16)&0x7FFF; }