X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fautouse.pm;h=a15d08abc55779d6558020858000d0030a4a62c9;hb=395b061e83a2cd1e977cf0ee574b2d0361cc1c0a;hp=b3adc34549f569c15f0ee5b0b7f55e41100c8a08;hpb=dc848c6f6758d4d951bb5c7a9f432e6390e094df;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/autouse.pm b/lib/autouse.pm index b3adc34..a15d08a 100644 --- a/lib/autouse.pm +++ b/lib/autouse.pm @@ -3,9 +3,9 @@ package autouse; #use strict; # debugging only use 5.003_90; # ->can, for my $var -$autouse::VERSION = '1.00'; +$autouse::VERSION = '1.01'; -my $DEBUG = $ENV{AUTOUSE_DEBUG}; +$autouse::DEBUG ||= 0; sub vet_import ($); @@ -15,7 +15,8 @@ sub croak { } sub import { - shift; + my $class = @_ ? shift : 'autouse'; + croak "usage: use $class MODULE [,SUBS...]" unless @_; my $module = shift; (my $pm = $module) =~ s{::}{/}g; @@ -29,7 +30,7 @@ sub import { # It is not loaded: need to do real work. my $callpkg = caller(0); - print "autouse called from $callpkg\n" if $DEBUG; + print "autouse called from $callpkg\n" if $autouse::DEBUG; my $index; for my $f (@_) { @@ -56,7 +57,7 @@ sub import { *$closure_import_func = \&{"${module}::$closure_func"}; print "autousing $module; " ."imported $closure_func as $closure_import_func\n" - if $DEBUG; + if $autouse::DEBUG; goto &$closure_import_func; };