Commit | Line | Data |
b1dbf716 |
1 | package # hide from PAUSE |
2 | DBIx::Class::_Util; |
3 | |
4 | use warnings; |
5 | use strict; |
6 | |
7 | use constant SPURIOUS_VERSION_CHECK_WARNINGS => ($] < 5.010 ? 1 : 0); |
8 | |
9 | use Carp; |
10 | |
11 | use base 'Exporter'; |
12 | our @EXPORT_OK = qw(modver_gt_or_eq); |
13 | |
14 | sub modver_gt_or_eq { |
15 | my ($mod, $ver) = @_; |
16 | |
17 | croak "Nonsensical module name supplied" |
18 | if ! defined $mod or ! length $mod; |
19 | |
20 | croak "Nonsensical minimum version supplied" |
21 | if ! defined $ver or $ver =~ /[^0-9\.\_]/; |
22 | |
23 | local $SIG{__WARN__} = do { |
24 | my $orig_sig_warn = $SIG{__WARN__} || sub { warn @_ }; |
25 | sub { |
26 | $orig_sig_warn->(@_) unless $_[0] =~ /\Qisn't numeric in subroutine entry/ |
27 | } |
28 | } if SPURIOUS_VERSION_CHECK_WARNINGS; |
29 | |
30 | local $@; |
31 | eval { $mod->VERSION($ver) } ? 1 : 0; |
32 | } |
33 | |
34 | 1; |