This code will pass 4294967296 (2**32) as a prime!
Quick fix:
sub RabinMiller
{
my $p = shift;
my $b = 0;
my $m = $p - 1;
my $t = 20; # The probability of error is .25 ** $t
# Probability of error with $t = 20 is lt 10 ** -12.
return 0 if ($p % 2 == 0 && $p > 2);
.....