autodi...dStack(3perl)
π autodi...dStack(3perl) β the hook stack that runs your cleanup at the exact right moment π
okay bestie, sit down, because this little page lives in the Perl Programmers Reference Guide and it is so niche and so good. if you've ever wondered how a pragma politely un-installs stuff when it goes out of scope, this is the β¨ machinery β¨. let's go π¦
πΈ NAME πΈ
autodie::Scope::GuardStack β Hook stack for managing scopes via %^H π
like. it's a stack. of hooks. that live in %^H. that's the whole vibe.
β¨ SYNOPSIS β¨
use autodie::Scope::GuardStack;
my $stack = autodie::Scope::GuardStack->new
$^H{'my-key'} = $stack;
$stack->push_hook(sub {});
the way you make one, shove it into %^H under your own key, and then yeet hooks at it. iconic behavior honestly π
(and yes, the ->new line above really does have no semicolon in the original. not me fixing it. not my job. iykyk π)
π DESCRIPTION π
so here's the tea π: this class is a stack of hooks β little subs β and it calls them in the right order as scopes go away. the stack is only useful when you insert it into %^H, and it will pop hooks as their "scope" gets popped. that's lowkey the entire point: it's for uninstalling or reinstalling subs in a namespace as a pragma goes out of scope. main character energy for cleanup code π
β οΈ now the part where you pay attention: because of how%^Hworks, this class is only useful during the compilation phase of a perl module, and it relies on perl's internals for how references are handled in%^H. also β and this is important, bestie β this module is not a part of autodie's public API. it's the private backstage area. no cap. π«Ά
π§ Methods π§
β new
my $stack = autodie::Scope::GuardStack->new;
creates a new autodie::Scope::GuardStack. β¨
the stack starts out empty β like, totally empty, no hooks, nothing β and the creator (that's you, babe) has to insert it into %^H themselves. it does not do that part for you π
β push_hook
$stack->push_hook(sub {});
adds a sub to the stack. π
that sub will get called once the current compile-time "scope" is left. and yes, you can add multiple hooks per scope β stack them up, bestie, they're all getting called. slay. π₯
π AUTHOR π
Copyright 2013, Niels Thykier <niels@thykier.net>
π LICENSE π
This module is free software. You may distribute it under the same terms as Perl itself.
okay that's the whole page, you ate it, you understood it, periodt π β¨
this was perl v5.44.0, dated 2026-10-17, and you just read the autodi...dStack(3perl) page. go be a legend with your hook stack, bestie ππ¦πΈ
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms