Fail early properly even in the presence of -jN
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / _Util.pm
CommitLineData
b1dbf716 1package # hide from PAUSE
2 DBIx::Class::_Util;
3
4use warnings;
5use strict;
6
7use constant SPURIOUS_VERSION_CHECK_WARNINGS => ($] < 5.010 ? 1 : 0);
8
9use Carp;
10
11use base 'Exporter';
12our @EXPORT_OK = qw(modver_gt_or_eq);
13
14sub 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
341;