From: Florian Ragwitz Date: Wed, 22 Oct 2008 15:47:29 +0000 (+0200) Subject: Port to B::Hooks::EndOfScope. X-Git-Tag: 0.09~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aa2aafaeb56dc0b50be2878642669c5ee17d944f;p=p5sagit%2Fnamespace-clean.git Port to B::Hooks::EndOfScope. --- diff --git a/Makefile.PL b/Makefile.PL index 07f8f62..bf6d28f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -12,7 +12,7 @@ all_from q{lib/namespace/clean.pm}; build_requires q{Test::More}, '0.62'; build_requires q{FindBin}, 0; -requires q{Scope::Guard}, '0.02'; +requires q{B::Hooks::EndOfScope}, 0; requires q{Symbol}, 0; auto_provides; diff --git a/lib/namespace/clean.pm b/lib/namespace/clean.pm index 86478cf..81da6f3 100644 --- a/lib/namespace/clean.pm +++ b/lib/namespace/clean.pm @@ -11,7 +11,7 @@ use strict; use vars qw( $VERSION $STORAGE_VAR $SCOPE_HOOK_KEY $SCOPE_EXPLICIT ); use Symbol qw( qualify_to_ref ); -use Scope::Guard; +use B::Hooks::EndOfScope; =head1 VERSION @@ -21,8 +21,6 @@ use Scope::Guard; $VERSION = 0.08; $STORAGE_VAR = '__NAMESPACE_CLEAN_STORAGE'; -$SCOPE_HOOK_KEY = 'namespace_clean_SCOPING'; -$SCOPE_EXPLICIT = 'namespace_clean_EXPLICIT'; =head1 SYNOPSIS @@ -157,7 +155,6 @@ my $RemoveSubs = sub { sub import { my ($pragma, @args) = @_; - $^H |= 0x120000; my (%args, $is_explicit); if (@args and $args[0] =~ /^\-/) { @@ -170,9 +167,9 @@ sub import { my $cleanee = caller; if ($is_explicit) { - $^H{ $SCOPE_EXPLICIT } = Scope::Guard->new(sub { + on_scope_end { $RemoveSubs->($cleanee, {}, @args); - }); + }; } else { @@ -197,9 +194,9 @@ sub import { # register EOF handler on first call to import unless ($store->{handler_is_installed}) { - $^H{ $SCOPE_HOOK_KEY } = Scope::Guard->new(sub { + on_scope_end { $RemoveSubs->($cleanee, $store, keys %{ $store->{remove} }); - }); + }; $store->{handler_is_installed} = 1; }