Skip to content

Commit b29ca71

Browse files
committed
Introduce helper function requires_by_perl
Function allows to specify multiple required version based on Perl version. Usable when module changes their Perl requirements.
1 parent 1bec90b commit b29ca71

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

cpanfile

+32
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
use strict; # satisfy linter
22
use warnings; # satisfy linter
33

4+
=pod
5+
6+
Semantic sugar to simplify management of modules which changed their required Perl version
7+
(directly or via dependencies)
8+
9+
requires_by_perl Module,
10+
prior 5.010 => 'use version X',
11+
prior 5.012 => 'use version Y',
12+
otherwise do_not_install
13+
;
14+
15+
=cut
16+
17+
sub requires_by_perl {
18+
my @requires = (shift);
19+
20+
while (@_) {
21+
shift, next
22+
unless @_ == 1 || $] < shift
23+
;
24+
25+
push @requires, shift // return;
26+
last;
27+
}
28+
29+
requires @requires;
30+
}
31+
32+
sub prior { @_ }
33+
sub otherwise { @_ }
34+
sub do_not_install { undef }
35+
436
# Last versions which install on < 5.12
537
if ( "$]" < 5.012 ) {
638
requires 'Data::Section', '==0.200007';

0 commit comments

Comments
 (0)