1autodie::Scope::GuardStUascekr(3C)ontributed Perl Documeanuttaotdiioen::Scope::GuardStack(3)
2
3
4

NAME

6       autodie::Scope::GuardStack -  Hook stack for managing scopes via %^H
7

SYNOPSIS

9           use autodie::Scope::GuardStack;
10           my $stack = autodie::Scope::GuardStack->new
11           $^H{'my-key'} = $stack;
12
13           $stack->push_hook(sub {});
14

DESCRIPTION

16       This class is a stack of hooks to be called in the right order as
17       scopes go away.  The stack is only useful when inserted into "%^H" and
18       will pop hooks as their "scope" is popped.  This is useful for
19       uninstalling or reinstalling subs in a namespace as a pragma goes out
20       of scope.
21
22       Due to how "%^H" works, this class is only useful during the
23       compilation phase of a perl module and relies on the internals of how
24       perl handles references in "%^H".  This module is not a part of
25       autodie's public API.
26
27   Methods
28       new
29
30         my $stack = autodie::Scope::GuardStack->new;
31
32       Creates a new "autodie::Scope::GuardStack".  The stack is initially
33       empty and must be inserted into "%^H" by the creator.
34
35       push_hook
36
37         $stack->push_hook(sub {});
38
39       Add a sub to the stack.  The sub will be called once the current
40       compile-time "scope" is left.  Multiple hooks can be added per scope
41

AUTHOR

43       Copyright 2013, Niels Thykier <niels@thykier.net>
44

LICENSE

46       This module is free software.  You may distribute it under the same
47       terms as Perl itself.
48
49
50
51perl v5.32.0                      2021-01-25     autodie::Scope::GuardStack(3)
Impressum