X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fnamespace%2Fclean.pm;h=5bd0b9ac2b1df73da6ddc3a6304efd612891caf4;hb=2f92146b7d8586bc062d3c587460caac27a27510;hp=86478cf751d594d4a7c05aedb0010fb38a15cc0d;hpb=de673bbfb3be8450727acc7e3aa6f806b8bf2482;p=p5sagit%2Fnamespace-clean.git diff --git a/lib/namespace/clean.pm b/lib/namespace/clean.pm index 86478cf..5bd0b9a 100644 --- a/lib/namespace/clean.pm +++ b/lib/namespace/clean.pm @@ -11,18 +11,16 @@ 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 -0.08 +0.10 =cut -$VERSION = 0.08; +$VERSION = '0.10'; $STORAGE_VAR = '__NAMESPACE_CLEAN_STORAGE'; -$SCOPE_HOOK_KEY = 'namespace_clean_SCOPING'; -$SCOPE_EXPLICIT = 'namespace_clean_EXPLICIT'; =head1 SYNOPSIS @@ -125,8 +123,8 @@ appropriate place. =head2 import -Makes a snapshot of the current defined functions and installs a -L in the current scope to invoke the cleanups. +Makes a snapshot of the current defined functions and installs a +L hook in the current scope to invoke the cleanups. =cut @@ -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; } @@ -287,7 +284,7 @@ use C instead. =head1 SEE ALSO -L +L =head1 AUTHOR AND COPYRIGHT