4 package B::Hooks::EndOfScope;
5 # ABSTRACT: Execute code after a scope finished compilation
8 use Variable::Magic 0.34;
10 use Sub::Exporter -setup => {
11 exports => ['on_scope_end'],
12 groups => { default => ['on_scope_end'] },
22 This module allows you to execute code when perl finished compiling the
31 Registers C<$code> to be executed after the surrounding scope has been
34 This is exported by default. See L<Sub::Exporter> on how to customize it.
39 my $wiz = Variable::Magic::wizard
40 data => sub { [$_[1]] },
41 free => sub { $_->() for @{ $_[1] }; () };
43 sub on_scope_end (&) {
48 if (my $stack = Variable::Magic::getdata %^H, $wiz) {
49 push @{ $stack }, $cb;
52 Variable::Magic::cast %^H, $wiz, $cb;