X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2Fsubs%2Fauto.pm;h=3a38497688c64975639d0c65dd529c858fb37cab;hb=0f17e772017f31694cc38cb6425922921a49d750;hp=20ff6d28377f5f950ce0dd55502c3c0a452b8f5c;hpb=3017ea00b43c676ffff95ae730c49656440d605c;p=perl%2Fmodules%2Fsubs-auto.git diff --git a/lib/subs/auto.pm b/lib/subs/auto.pm index 20ff6d2..3a38497 100644 --- a/lib/subs/auto.pm +++ b/lib/subs/auto.pm @@ -16,11 +16,11 @@ subs::auto - Read barewords as subroutine names. =head1 VERSION -Version 0.02 +Version 0.03 =cut -our $VERSION = '0.02'; +our $VERSION = '0.03'; =head1 SYNOPSIS @@ -119,15 +119,14 @@ sub _reset { sub _fetch { (undef, my $data, my $func) = @_; - return if $data->{guard}; - return unless $func !~ /::/ and not exists $core{$func}; - local $data->{guard} = 1; + return if $data->{guard} or $func =~ /::/ or exists $core{$func}; + $data->{guard} = 1; my $hints = (caller 0)[10]; if ($hints and $hints->{subs__auto}) { my $mod = $func . '.pm'; if (not exists $INC{$mod}) { my $fqn = $data->{pkg} . '::' . $func; - if (do { no strict 'refs'; not *$fqn{CODE} and not *$fqn{IO}}) { + if (do { no strict 'refs'; not *$fqn{CODE} || *$fqn{IO}}) { my $cb = sub { my ($file, $line) = (caller 0)[1, 2]; ($file, $line) = ('(eval 0)', 0) unless $file && $line; @@ -141,14 +140,16 @@ sub _fetch { } else { _reset($data->{pkg}, $func); } + $data->{guard} = 0; return; } sub _store { (undef, my $data, my $func) = @_; return if $data->{guard}; - local $data->{guard} = 1; + $data->{guard} = 1; _reset($data->{pkg}, $func); + $data->{guard} = 0; return; }