Skip to content

Commit 2eaeb95

Browse files
authored
Merge pull request #406 from mknos/primes-valid
primes: error for numbers with trailing non-digits
2 parents 528789b + 4d1f3c2 commit 2eaeb95

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bin/primes

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ END {
3030
chomp(my $start = @ARGV ? $ARGV[0] : <STDIN>);
3131
my $end = $ARGV[1] || 2**32 - 1;
3232
for ($start, $end) {
33-
s/^\s*\+?(\d{1,10}).*/$1/ || die "$0: $_: illegal numeric format\n";
33+
s/\A\s*\+?(\d{1,10})\Z/$1/ || die "$0: $_: illegal numeric format\n";
3434
$_ > 2**32 - 1 && die "$0: $_: Numerical result out of range\n";
3535
}
3636
die "$0: start value must be less than stop value\n" if ($end < $start);

0 commit comments

Comments
 (0)