use bigint; my $state = 0; sub rand { $state = ($state + 1) % (2 ** 19937 - 1); $state & 0xFFFFFFFF; }