X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fautouse.pm;h=67c4e01d1dea384b943c9b0cb2896324aec087a4;hb=e82b93481bc82235f35444c372503cc96abe405b;hp=68646a47201d35e7427a580b2e78fd48b1e15e87;hpb=d6a466d771dbdc293e3f83b595b03cf44617cabb;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/autouse.pm b/lib/autouse.pm index 68646a4..67c4e01 100644 --- a/lib/autouse.pm +++ b/lib/autouse.pm @@ -3,7 +3,7 @@ package autouse; #use strict; # debugging only use 5.003_90; # ->can, for my $var -$autouse::VERSION = '1.03'; +$autouse::VERSION = '1.05'; $autouse::DEBUG ||= 0; @@ -50,8 +50,7 @@ sub import { my $load_sub = sub { unless ($INC{$pm}) { - eval {require $pm}; - die if $@; + require $pm; vet_import $module; } no warnings 'redefine'; @@ -63,7 +62,8 @@ sub import { }; if (defined $proto) { - *$closure_import_func = eval "sub ($proto) { &\$load_sub }"; + *$closure_import_func = eval "sub ($proto) { goto &\$load_sub }" + || die; } else { *$closure_import_func = $load_sub; } @@ -73,9 +73,10 @@ sub import { sub vet_import ($) { my $module = shift; if (my $import = $module->can('import')) { - croak "autoused module has unique import() method" + croak "autoused module $module has unique import() method" unless defined(&Exporter::import) - && $import == \&Exporter::import; + && ($import == \&Exporter::import || + $import == \&UNIVERSAL::import) } }