{
    "content": [
        {
            "type": "text",
            "text": "# autodie (man)\n\n## NAME\n\nautodie - Replace functions with ones that succeed or die with lexical scope\n\n## SYNOPSIS\n\nuse autodie;            # Recommended: implies 'use autodie qw(:default)'\nuse autodie qw(:all);   # Recommended more: defaults and system/exec.\nuse autodie qw(open close);   # open/close succeed or die\nopen(my $fh, \"<\", $filename); # No need to check!\n{\nno autodie qw(open);          # open failures won't die\nopen(my $fh, \"<\", $filename); # Could fail silently!\nno autodie;                   # disable all autodies\n}\nprint \"Hello World\" or die $!;    # autodie DOESN'T check print!\n\n## DESCRIPTION\n\nbIlujDI' yIchegh()Qo'; yIHegh()!\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **EXCEPTIONS**\n- **CATEGORIES**\n- **FUNCTION SPECIFIC NOTES** (3 subsections)\n- **GOTCHAS**\n- **DIAGNOSTICS** (2 subsections)\n- **BUGS** (1 subsections)\n- **FEEDBACK**\n- **AUTHOR**\n- **LICENSE**\n- **SEE ALSO**\n- **ACKNOWLEDGEMENTS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "autodie",
        "section": "",
        "mode": "man",
        "summary": "autodie - Replace functions with ones that succeed or die with lexical scope",
        "synopsis": "use autodie;            # Recommended: implies 'use autodie qw(:default)'\nuse autodie qw(:all);   # Recommended more: defaults and system/exec.\nuse autodie qw(open close);   # open/close succeed or die\nopen(my $fh, \"<\", $filename); # No need to check!\n{\nno autodie qw(open);          # open failures won't die\nopen(my $fh, \"<\", $filename); # Could fail silently!\nno autodie;                   # disable all autodies\n}\nprint \"Hello World\" or die $!;    # autodie DOESN'T check print!",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "EXCEPTIONS",
                "lines": 24,
                "subsections": []
            },
            {
                "name": "CATEGORIES",
                "lines": 93,
                "subsections": []
            },
            {
                "name": "FUNCTION SPECIFIC NOTES",
                "lines": 1,
                "subsections": [
                    {
                        "name": "print",
                        "lines": 2
                    },
                    {
                        "name": "flock",
                        "lines": 12
                    },
                    {
                        "name": "system/exec",
                        "lines": 24
                    }
                ]
            },
            {
                "name": "GOTCHAS",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "DIAGNOSTICS",
                "lines": 16,
                "subsections": [
                    {
                        "name": "Tips and Tricks",
                        "lines": 1
                    },
                    {
                        "name": "Importing autodie into another namespace than \"caller\"",
                        "lines": 3
                    }
                ]
            },
            {
                "name": "BUGS",
                "lines": 14,
                "subsections": [
                    {
                        "name": "autodie and string eval",
                        "lines": 17
                    }
                ]
            },
            {
                "name": "FEEDBACK",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "ACKNOWLEDGEMENTS",
                "lines": 8,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "autodie - Replace functions with ones that succeed or die with lexical scope\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use autodie;            # Recommended: implies 'use autodie qw(:default)'\n\nuse autodie qw(:all);   # Recommended more: defaults and system/exec.\n\nuse autodie qw(open close);   # open/close succeed or die\n\nopen(my $fh, \"<\", $filename); # No need to check!\n\n{\nno autodie qw(open);          # open failures won't die\nopen(my $fh, \"<\", $filename); # Could fail silently!\nno autodie;                   # disable all autodies\n}\n\nprint \"Hello World\" or die $!;    # autodie DOESN'T check print!\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "bIlujDI' yIchegh()Qo'; yIHegh()!\n\nIt is better to die() than to return() in failure.\n\n-- Klingon programming proverb.\n\nThe \"autodie\" pragma provides a convenient way to replace functions that normally return\nfalse on failure with equivalents that throw an exception on failure.\n\nThe \"autodie\" pragma has lexical scope, meaning that functions and subroutines altered with\n\"autodie\" will only change their behaviour until the end of the enclosing block, file, or\n\"eval\".\n\nIf \"system\" is specified as an argument to \"autodie\", then it uses IPC::System::Simple to do\nthe heavy lifting.  See the description of that module for more information.\n",
                "subsections": []
            },
            "EXCEPTIONS": {
                "content": "Exceptions produced by the \"autodie\" pragma are members of the autodie::exception class.  The\npreferred way to work with these exceptions under Perl 5.10 is as follows:\n\neval {\nuse autodie;\n\nopen(my $fh, '<', $somefile);\n\nmy @records = <$fh>;\n\n# Do things with @records...\n\nclose($fh);\n};\n\nif ($@ and $@->isa('autodie::exception')) {\nif ($@->matches('open')) { print \"Error from open\\n\";   }\nif ($@->matches(':io' )) { print \"Non-open, IO error.\"; }\n} elsif ($@) {\n# A non-autodie exception.\n}\n\nSee autodie::exception for further information on interrogating exceptions.\n",
                "subsections": []
            },
            "CATEGORIES": {
                "content": "Autodie uses a simple set of categories to group together similar built-ins.  Requesting a\ncategory type (starting with a colon) will enable autodie for all built-ins beneath that\ncategory.  For example, requesting \":file\" will enable autodie for \"close\", \"fcntl\", \"open\"\nand \"sysopen\".\n\nThe categories are currently:\n\n:all\n:default\n:io\nread\nseek\nsysread\nsysseek\nsyswrite\n:dbm\ndbmclose\ndbmopen\n:file\nbinmode\nclose\nchmod\nchown\nfcntl\nflock\nioctl\nopen\nsysopen\ntruncate\n:filesys\nchdir\nclosedir\nopendir\nlink\nmkdir\nreadlink\nrename\nrmdir\nsymlink\nunlink\n:ipc\nkill\npipe\n:msg\nmsgctl\nmsgget\nmsgrcv\nmsgsnd\n:semaphore\nsemctl\nsemget\nsemop\n:shm\nshmctl\nshmget\nshmread\n:socket\naccept\nbind\nconnect\ngetsockopt\nlisten\nrecv\nsend\nsetsockopt\nshutdown\nsocketpair\n:threads\nfork\n:system\nsystem\nexec\n\nNote that while the above category system is presently a strict hierarchy, this should not be\nassumed.\n\nA plain \"use autodie\" implies \"use autodie qw(:default)\".  Note that \"system\" and \"exec\" are\nnot enabled by default.  \"system\" requires the optional IPC::System::Simple module to be\ninstalled, and enabling \"system\" or \"exec\" will invalidate their exotic forms.  See \"BUGS\"\nbelow for more details.\n\nThe syntax:\n\nuse autodie qw(:1.994);\n\nallows the \":default\" list from a particular version to be used.  This provides the\nconvenience of using the default methods, but the surety that no behavioral changes will\noccur if the \"autodie\" module is upgraded.\n\n\"autodie\" can be enabled for all of Perl's built-ins, including \"system\" and \"exec\" with:\n\nuse autodie qw(:all);\n",
                "subsections": []
            },
            "FUNCTION SPECIFIC NOTES": {
                "content": "",
                "subsections": [
                    {
                        "name": "print",
                        "content": "The autodie pragma does not check calls to \"print\".\n"
                    },
                    {
                        "name": "flock",
                        "content": "It is not considered an error for \"flock\" to return false if it fails due to an \"EWOULDBLOCK\"\n(or equivalent) condition.  This means one can still use the common convention of testing the\nreturn value of \"flock\" when called with the \"LOCKNB\" option:\n\nuse autodie;\n\nif ( flock($fh, LOCKEX | LOCKNB) ) {\n# We have a lock\n}\n\nAutodying \"flock\" will generate an exception if \"flock\" returns false with any other error.\n"
                    },
                    {
                        "name": "system/exec",
                        "content": "The \"system\" built-in is considered to have failed in the following circumstances:\n\n•   The command does not start.\n\n•   The command is killed by a signal.\n\n•   The command returns a non-zero exit value (but see below).\n\nOn success, the autodying form of \"system\" returns the exit value rather than the contents of\n$?.\n\nAdditional allowable exit values can be supplied as an optional first argument to autodying\n\"system\":\n\nsystem( [ 0, 1, 2 ], $cmd, @args);  # 0,1,2 are good exit values\n\n\"autodie\" uses the IPC::System::Simple module to change \"system\".  See its documentation for\nfurther information.\n\nApplying \"autodie\" to \"system\" or \"exec\" causes the exotic forms \"system { $cmd } @args \" or\n\"exec { $cmd } @args\" to be considered a syntax error until the end of the lexical scope.  If\nyou really need to use the exotic form, you can call \"CORE::system\" or \"CORE::exec\" instead,\nor use \"no autodie qw(system exec)\" before calling the exotic form.\n"
                    }
                ]
            },
            "GOTCHAS": {
                "content": "Functions called in list context are assumed to have failed if they return an empty list, or\na list consisting only of a single undef element.\n\nSome builtins (e.g. \"chdir\" or \"truncate\") has a call signature that cannot completely be\nrepresented with a Perl prototype.  This means that some valid Perl code will be invalid\nunder autodie.  As an example:\n\nchdir(BAREWORD);\n\nWithout autodie (and assuming BAREWORD is an open filehandle/dirhandle) this is a valid call\nto chdir.  But under autodie, \"chdir\" will behave like it had the prototype \";$\" and thus\nBAREWORD will be a syntax error (under \"use strict\".  Without strict, it will interpreted as\na filename).\n",
                "subsections": []
            },
            "DIAGNOSTICS": {
                "content": ":void cannot be used with lexical scope\nThe \":void\" option is supported in Fatal, but not \"autodie\".  To workaround this,\n\"autodie\" may be explicitly disabled until the end of the current block with \"no\nautodie\".  To disable autodie for only a single function (eg, open) use \"no autodie\nqw(open)\".\n\n\"autodie\" performs no checking of called context to determine whether to throw an\nexception; the explicitness of error handling with \"autodie\" is a deliberate feature.\n\nNo user hints defined for %s\nYou've insisted on hints for user-subroutines, either by pre-pending a \"!\" to the\nsubroutine name itself, or earlier in the list of arguments to \"autodie\".  However the\nsubroutine in question does not have any hints available.\n\nSee also \"DIAGNOSTICS\" in Fatal.\n",
                "subsections": [
                    {
                        "name": "Tips and Tricks",
                        "content": ""
                    },
                    {
                        "name": "Importing autodie into another namespace than \"caller\"",
                        "content": "It is possible to import autodie into a different namespace by using Import::Into.  However,\nyou have to pass a \"caller depth\" (rather than a package name) for this to work correctly.\n"
                    }
                ]
            },
            "BUGS": {
                "content": "\"Used only once\" warnings can be generated when \"autodie\" or \"Fatal\" is used with package\nfilehandles (eg, \"FILE\").  Scalar filehandles are strongly recommended instead.\n\nWhen using \"autodie\" or \"Fatal\" with user subroutines, the declaration of those subroutines\nmust appear before the first use of \"Fatal\" or \"autodie\", or have been exported from a\nmodule.  Attempting to use \"Fatal\" or \"autodie\" on other user subroutines will result in a\ncompile-time error.\n\nDue to a bug in Perl, \"autodie\" may \"lose\" any format which has the same name as an autodying\nbuilt-in or function.\n\n\"autodie\" may not work correctly if used inside a file with a name that looks like a string\neval, such as eval (3).\n",
                "subsections": [
                    {
                        "name": "autodie and string eval",
                        "content": "Due to the current implementation of \"autodie\", unexpected results may be seen when used near\nor with the string version of eval.  None of these bugs exist when using block eval.\n\nUnder Perl 5.8 only, \"autodie\" does not propagate into string \"eval\" statements, although it\ncan be explicitly enabled inside a string \"eval\".\n\nUnder Perl 5.10 only, using a string eval when \"autodie\" is in effect can cause the autodie\nbehaviour to leak into the surrounding scope.  This can be worked around by using a \"no\nautodie\" at the end of the scope to explicitly remove autodie's effects, or by avoiding the\nuse of string eval.\n\nNone of these bugs exist when using block eval.  The use of \"autodie\" with block eval is\nconsidered good practice.\n\nREPORTING BUGS\nPlease report bugs via the GitHub Issue Tracker at <https://github.com/pjf/autodie/issues>.\n"
                    }
                ]
            },
            "FEEDBACK": {
                "content": "If you find this module useful, please consider rating it on the CPAN Ratings service at\n<http://cpanratings.perl.org/rate?distribution=autodie> .\n\nThe module author loves to hear how \"autodie\" has made your life better (or worse).  Feedback\ncan be sent to <pjf@perltraining.com.au>.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Copyright 2008-2009, Paul Fenwick <pjf@perltraining.com.au>\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "This module is free software.  You may distribute it under the same terms as Perl itself.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Fatal, autodie::exception, autodie::hints, IPC::System::Simple\n\nPerl tips, autodie at <http://perltraining.com.au/tips/2008-08-20.html>\n",
                "subsections": []
            },
            "ACKNOWLEDGEMENTS": {
                "content": "Mark Reed and Roland Giersig -- Klingon translators.\n\nSee the AUTHORS file for full credits.  The latest version of this file can be found at\n<https://github.com/pjf/autodie/tree/master/AUTHORS> .\n\n\n\nperl v5.34.0                                 2025-07-25                               autodie(3perl)",
                "subsections": []
            }
        }
    }
}