logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

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

Author

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

Description

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. Methodsnew 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

License

This module is free software. You may distribute it under the same terms as Perl itself. perl v5.40.1 2025-07-03 autodie::Scope::GuardStack(3perl)

Name

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

Synopsis

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

See Also