X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FConfig%2FAny%2FBase.pm;h=3f05e0f4d8468c45554c428210cf4ab72299e153;hb=8c6349de453e95debad3f72cce78563710518d57;hp=2826cb6b53121276164249c78fcf5988040c18fa;hpb=19f6cb6387c498de75ffc388b5db53c9da678e05;p=p5sagit%2FConfig-Any.git diff --git a/lib/Config/Any/Base.pm b/lib/Config/Any/Base.pm index 2826cb6..3f05e0f 100644 --- a/lib/Config/Any/Base.pm +++ b/lib/Config/Any/Base.pm @@ -38,15 +38,16 @@ Lack of specifying these subs will assume you require no extra modules to functi sub is_supported { my ( $class ) = shift; + local $@; if ( $class->can( 'requires_all_of' ) ) { - eval join( '', map { _require_line( $_ ) } $class->requires_all_of ); - return $@ ? 0 : 1; + return eval { + _require($_) for $class->requires_all_of; + 1; + } || 0; } if ( $class->can( 'requires_any_of' ) ) { - for ( $class->requires_any_of ) { - eval _require_line( $_ ); - return 1 unless $@; - } + eval { _require( $_ ); 1 } and return 1 + for $class->requires_any_of; return 0; } @@ -54,16 +55,17 @@ sub is_supported { return 1; } -sub _require_line { +sub _require { my ( $input ) = shift; my ( $module, $version ) = ( ref $input ? @$input : $input ); - return "require $module;" - . ( $version ? "${module}->VERSION('${version}');" : '' ); + (my $file = "$module.pm") =~ s{::}{/}g; + require $file; + $module->VERSION if $version; } =head1 AUTHOR -Brian Cassidy Ebricas@cpan.orgE +Brian Cassidy =head1 COPYRIGHT AND LICENSE