This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fixes to compile Perl with g++ and DEBUGGING.
[perl5.git] / lib / autouse.pm
index a5efaac..cbde386 100644 (file)
@@ -1,9 +1,9 @@
 package autouse;
 
 #use strict;           # debugging only
-use 5.003_90;          # ->can, for my $var
+use 5.006;             # use warnings
 
-$autouse::VERSION = '1.03';
+$autouse::VERSION = '1.06';
 
 $autouse::DEBUG ||= 0;
 
@@ -50,11 +50,10 @@ sub import {
 
        my $load_sub = sub {
            unless ($INC{$pm}) {
-               eval {require $pm};
-               die if $@;
+               require $pm;
                vet_import $module;
            }
-            no warnings 'redefine';
+            no warnings qw(redefine prototype);
            *$closure_import_func = \&{"${module}::$closure_func"};
            print "autousing $module; "
                  ."imported $closure_func as $closure_import_func\n"
@@ -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;
        }