use strict; use warnings; my $num; my $result; my @array = (2, 3, 4, 5, 6); for (;;) { print ("Please enter the number.(Enter exit at the end) "); $num = ; chomp $num; if ($num =~ /[a-zA-Z]/ || $num eq "") { exit; } $result = ($num . " = "); my $j = 0; while ($j < scalar(@array)) { $result .= ("[" . $array[$j] . "]" . (($num % $array[$j]) == 0 ? "OK" : "NG")); $j++; } $result .= "\n"; print ($result); }