autodie::Scope::GuardStack(3p)

autodie::Scope::GuardStack3p

Hook stack for managing scopes via %^h

Usage

    use autodie::Scope::GuardStack;
    my $stack = autodie::Scope::GuardStack->new
    $^H{'my-key'} = $stack;
    $stack->push_hook(sub {});

Overview

This class is a stack of hooks to be called in the right order as scopes go away. The stack is only useful when inserted into "%^H" and will pop hooks as their "scope" is popped. This is useful for uninstalling or reinstalling subs in a namespace as a pragma goes out of scope.

Due to how "%^H" works, this class is only useful during the compilation phase of a perl module and relies on the internals of how perl handles references in "%^H". This module is not a part of autodie's public API.

Methods

new

  my $stack = autodie::Scope::GuardStack->new;

Creates a new "autodie::Scope::GuardStack". The stack is initially empty and must be inserted into "%^H" by the creator.

push_hook

  $stack->push_hook(sub {});

Add a sub to the stack. The sub will be called once the current compile-time "scope" is left. Multiple hooks can be added per scope

Releases

21 releases since OpenBSD 6.1; the text changed 14 times.

  1. 6.1
  2. 6.2
  3. 6.3–6.4
  4. 6.5
  5. 6.6
  6. 6.7
  7. 6.8
  8. 6.9–7.2
  9. 7.3
  10. 7.4
  11. 7.5
  12. 7.6
  13. 7.7–7.8
  14. 7.9
  15. 8.0

Author

Copyright 2013, Niels Thykier <[email protected]>

License

This module is free software. You may distribute it under the same terms as Perl itself.

From man 8.0-current-20261101 in OpenBSD 8.0-current (2026-11-01). Parsed by carta from the page's man source.