{
    "mode": "perldoc",
    "parameter": "longjmp",
    "section": "-q",
    "url": "https://www.chedong.com/phpMan.php/perldoc/longjmp/json",
    "generated": "2026-11-22T20:49:15Z",
    "sections": {
        "Found in /usr/share/perl/5.38/pod/perlfaq8.pod": {
            "content": "How can I do an atexit() or setjmp()/longjmp()? (Exception handling)\nYou can use the \"END\" block to simulate atexit(). Each package's \"END\"\nblock is called when the program or thread ends. See the perlmod manpage\nfor more details about \"END\" blocks.\n\nFor example, you can use this to make sure your filter program managed\nto finish its output without filling up the disk:\n\nEND {\nclose(STDOUT) || die \"stdout close failed: $!\";\n}\n\nThe \"END\" block isn't called when untrapped signals kill the program,\nthough, so if you use \"END\" blocks you should also use\n\nuse sigtrap qw(die normal-signals);\n\nPerl's exception-handling mechanism is its eval() operator. You can use\neval() as \"setjmp\" and die() as \"longjmp\". For details of this, see the\nsection on signals, especially the time-out handler for a blocking\nflock() in \"Signals\" in perlipc or the section on \"Signals\" in\n*Programming Perl*.\n\nIf exception handling is all you're interested in, use one of the many\nCPAN modules that handle exceptions, such as Try::Tiny.\n\nIf you want the atexit() syntax (and an rmexit() as well), try the\n\"AtExit\" module available from CPAN.\n",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}