4 package B::Hooks::EndOfScope;
11 use Sub::Exporter -setup => {
12 exports => ['on_scope_end'],
13 groups => { default => ['on_scope_end'] },
18 B::Hooks::EndOfScope - Execute code after a scope finished compilation
26 This module allows you to execute code when perl finished compiling the
37 Registers C<$code> to be executed after the surrounding scope has been
40 This is exported by default. See L<Sub::Exporter> on how to customize it.
45 my $wiz = Variable::Magic::wizard
46 data => sub { [$_[1]] },
47 free => sub { $_->() for @{ $_[1] }; () };
49 sub on_scope_end (&) {
54 if (my $stack = Variable::Magic::getdata %^H, $wiz) {
55 push @{ $stack }, $cb;
58 Variable::Magic::cast %^H, $wiz, $cb;
71 Florian Ragwitz E<lt>rafl@debian.orgE<gt>
73 =head1 COPYRIGHT AND LICENSE
75 Copyright (c) 2008 Florian Ragwitz
77 This module is free software.
79 You may distribute this code under the same terms as Perl itself.