Skip to content

Commit

Permalink
/a modifier on regexes is a 5.14-ism
Browse files Browse the repository at this point in the history
  • Loading branch information
DrHyde committed Oct 29, 2022
1 parent c9cf57e commit 2244bdd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions lib/Devel/Deprecations/Plugin/OldPerl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ sub is_deprecated {
my $minimum_version = $_[-1]->{older_than} ||
die(__PACKAGE__.": 'older_than' parameter is mandatory\n");
my @minimum_version_parts = (split(/\./, "$minimum_version", 3), 0, 0)[0..2];
die(__PACKAGE__.": $minimum_version isn't a plausible perl version\n")
if(grep { /\D/a } @minimum_version_parts);

# can't use /\D/a because /a is a 5.14-ism
if(grep { /[^0-9]/ } @minimum_version_parts) {
die(__PACKAGE__.": $minimum_version isn't a plausible perl version\n")
}

my @current_version_parts = split(/\./, $Config{version});

Expand Down
8 changes: 4 additions & 4 deletions t/oldperl.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ my $this_perl = sprintf("%d.%d.%d", @parts);
my $future_perl = sprintf("%d.%d.%d", $parts[0], $parts[1] + 2, 0);

subtest "ridiculous invocations" => sub {
dies_ok {
throws_ok {
Devel::Deprecations->import('OldPerl')
} "no args";
dies_ok {
} qr/parameter is mandatory/, "dies with no args";
throws_ok {
Devel::Deprecations->import(OldPerl => { older_than => "a lemon" })
} "implausible version";
} qr/plausible perl version/, "dies with implausible version";
};

subtest "this perl ($this_perl) is OK" => sub {
Expand Down

0 comments on commit 2244bdd

Please sign in to comment.