{
    "mode": "perldoc",
    "parameter": "autodie::Scope::GuardStack",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/autodie%3A%3AScope%3A%3AGuardStack/json",
    "generated": "2026-06-10T13:18:39Z",
    "synopsis": "use autodie::Scope::GuardStack;\nmy $stack = autodie::Scope::GuardStack->new\n$^H{'my-key'} = $stack;\n$stack->pushhook(sub {});",
    "sections": {
        "NAME": {
            "content": "autodie::Scope::GuardStack - Hook stack for managing scopes via %^H\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use autodie::Scope::GuardStack;\nmy $stack = autodie::Scope::GuardStack->new\n$^H{'my-key'} = $stack;\n\n$stack->pushhook(sub {});\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This class is a stack of hooks to be called in the right order as scopes go away. The stack is\nonly useful when inserted into \"%^H\" and will pop hooks as their \"scope\" is popped. This is\nuseful for uninstalling or reinstalling subs in a namespace as a pragma goes out of scope.\n\nDue to how \"%^H\" works, this class is only useful during the compilation phase of a perl module\nand relies on the internals of how perl handles references in \"%^H\". This module is not a part\nof autodie's public API.\n",
            "subsections": [
                {
                    "name": "Methods",
                    "content": "new\nmy $stack = autodie::Scope::GuardStack->new;\n\nCreates a new \"autodie::Scope::GuardStack\". The stack is initially empty and must be inserted\ninto \"%^H\" by the creator.\n\npushhook\n$stack->pushhook(sub {});\n\nAdd a sub to the stack. The sub will be called once the current compile-time \"scope\" is left.\nMultiple hooks can be added per scope\n"
                }
            ]
        },
        "AUTHOR": {
            "content": "Copyright 2013, Niels Thykier <niels@thykier.net>\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "This module is free software. You may distribute it under the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "autodie::Scope::GuardStack - Hook stack for managing scopes via %^H",
    "flags": [],
    "examples": [],
    "see_also": []
}