{
    "mode": "perldoc",
    "parameter": "B::Hooks::EndOfScope",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/B%3A%3AHooks%3A%3AEndOfScope/json",
    "generated": "2026-06-12T05:49:56Z",
    "synopsis": "onscopeend { ... };",
    "sections": {
        "NAME": {
            "content": "B::Hooks::EndOfScope - Execute code after a scope finished compilation\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 0.25\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "onscopeend { ... };\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module allows you to execute code when perl finished compiling the surrounding scope.\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "onscopeend\nonscopeend { ... };\n\nonscopeend $code;\n\nRegisters $code to be executed after the surrounding scope has been compiled.\n\nThis is exported by default. See Sub::Exporter on how to customize it.\n",
            "subsections": []
        },
        "LIMITATIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "Pure-perl mode caveat",
                    "content": "This caveat applies to any version of perl where Variable::Magic is unavailable or otherwise\ndisabled.\n\nWhile Variable::Magic has access to some very dark sorcery to make it possible to throw an\nexception from within a callback, the pure-perl implementation does not have access to these\nhacks. Therefore, what would have been a compile-time exception is instead converted to a\nwarning, and your execution will continue as if the exception never happened.\n\nTo explicitly request an XS (or PP) implementation one has two choices. Either to import from\nthe desired implementation explicitly:\n\nuse B::Hooks::EndOfScope::XS\nor\nuse B::Hooks::EndOfScope::PP\n\nor by setting $ENV{BHOOKSENDOFSCOPEIMPLEMENTATION} to either \"XS\" or \"PP\".\n\nPerl 5.8.0 ~ 5.8.3\nDue to a core interpreter bug <https://rt.perl.org/Public/Bug/Display.html?id=27040#txn-82797>\npresent in older perl versions, the implementation of B::Hooks::EndOfScope deliberately leaks a\nsingle empty hash for every scope being cleaned. This is done to avoid the memory corruption\nassociated with the bug mentioned above.\n\nIn order to stabilize this workaround use of Variable::Magic is disabled on perls prior to\nversion 5.8.4. On such systems loading/requesting B::Hooks::EndOfScope::XS explicitly will\nresult in a compile-time exception.\n"
                },
                {
                    "name": "Perl versions 5.6.x",
                    "content": "Versions of perl before 5.8.0 lack a feature allowing changing the visibility of \"%^H\" via\nsetting bit 17 within $^H. As such the only way to achieve the effect necessary for this module\nto work, is to use the \"local\" operator explicitly on these platforms. This might lead to\nunexpected interference with other scope-driven libraries relying on the same mechanism. On the\nflip side there are no such known incompatibilities at the time this note was written.\n\nFor further details on the unavailable behavior please refer to the test file t/02-localise.t\nincluded with the distribution.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "Sub::Exporter\n\nVariable::Magic\n",
            "subsections": []
        },
        "SUPPORT": {
            "content": "Bugs may be submitted through the RT bug tracker\n<https://rt.cpan.org/Public/Dist/Display.html?Name=B-Hooks-EndOfScope> (or\nbug-B-Hooks-EndOfScope@rt.cpan.org <mailto:bug-B-Hooks-EndOfScope@rt.cpan.org>).\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "*   Florian Ragwitz <rafl@debian.org>\n\n*   Peter Rabbitson <ribasushi@leporine.io>\n",
            "subsections": []
        },
        "CONTRIBUTORS": {
            "content": "*   Karen Etheridge <ether@cpan.org>\n\n*   Christian Walde <walde.christian@googlemail.com>\n\n*   Graham Knop <haarg@haarg.org>\n\n*   Simon Wilper <sxw@chronowerks.de>\n\n*   Tatsuhiko Miyagawa <miyagawa@bulknews.net>\n\n*   Tomas Doran <bobtfish@bobtfish.net>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENCE": {
            "content": "This software is copyright (c) 2008 by Florian Ragwitz.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        }
    },
    "summary": "B::Hooks::EndOfScope - Execute code after a scope finished compilation",
    "flags": [],
    "examples": [],
    "see_also": []
}