From: gfx Date: Thu, 27 Aug 2009 08:34:47 +0000 (+0900) Subject: Use Module::Info instead of eval "require $mod" in Makefile.PL X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e97ccbf1197c33b578660130de21e8db80e8e2bb;p=gitmo%2FClass-MOP.git Use Module::Info instead of eval "require $mod" in Makefile.PL --- diff --git a/Makefile.PL b/Makefile.PL index b6a5b5c..729eee2 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -70,13 +70,16 @@ sub check_conflicts { 'Moose' => '0.85', ); + my $has_module_info = eval{ require Module::Info }; + my $get_version = $has_module_info + ? sub{ Module::Info->new_from_module($_[0])->version } + : sub{ eval qq{ require $_[0] } ? $_[0]->VERSION : undef }; + my $found = 0; for my $mod ( sort keys %conflicts ) { - eval "require $mod"; - next if $@; + my $installed = $get_version->($mod); - my $installed = $mod->VERSION(); - if ( $installed le $conflicts{$mod} ) { + if ( defined($installed) && $installed le $conflicts{$mod} ) { print <<"EOF";