{
    "content": [
        {
            "type": "text",
            "text": "# AutoLoader (man)\n\n## NAME\n\nAutoLoader - load subroutines only on demand\n\n## SYNOPSIS\n\npackage Foo;\nuse AutoLoader 'AUTOLOAD';   # import the default AUTOLOAD subroutine\npackage Bar;\nuse AutoLoader;              # don't import AUTOLOAD, define our own\nsub AUTOLOAD {\n...\n$AutoLoader::AUTOLOAD = \"...\";\ngoto &AutoLoader::AUTOLOAD;\n}\n\n## DESCRIPTION\n\nThe AutoLoader module works with the AutoSplit module and the \"END\" token to defer the\nloading of some subroutines until they are used rather than loading them all at once.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (7 subsections)\n- **CAVEATS**\n- **SEE ALSO**\n- **AUTHOR**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "AutoLoader",
        "section": "",
        "mode": "man",
        "summary": "AutoLoader - load subroutines only on demand",
        "synopsis": "package Foo;\nuse AutoLoader 'AUTOLOAD';   # import the default AUTOLOAD subroutine\npackage Bar;\nuse AutoLoader;              # don't import AUTOLOAD, define our own\nsub AUTOLOAD {\n...\n$AutoLoader::AUTOLOAD = \"...\";\ngoto &AutoLoader::AUTOLOAD;\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 19,
                "subsections": [
                    {
                        "name": "Subroutine Stubs",
                        "lines": 13
                    },
                    {
                        "name": "Using AutoLoader's AUTOLOAD Subroutine",
                        "lines": 4
                    },
                    {
                        "name": "Overriding AutoLoader's AUTOLOAD Subroutine",
                        "lines": 31
                    },
                    {
                        "name": "Package Lexicals",
                        "lines": 10
                    },
                    {
                        "name": "Not Using AutoLoader",
                        "lines": 4
                    },
                    {
                        "name": "AutoLoader vs. SelfLoader",
                        "lines": 12
                    },
                    {
                        "name": "Forcing AutoLoader to Load a Function",
                        "lines": 10
                    }
                ]
            },
            {
                "name": "CAVEATS",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 60,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "AutoLoader - load subroutines only on demand\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "package Foo;\nuse AutoLoader 'AUTOLOAD';   # import the default AUTOLOAD subroutine\n\npackage Bar;\nuse AutoLoader;              # don't import AUTOLOAD, define our own\nsub AUTOLOAD {\n...\n$AutoLoader::AUTOLOAD = \"...\";\ngoto &AutoLoader::AUTOLOAD;\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The AutoLoader module works with the AutoSplit module and the \"END\" token to defer the\nloading of some subroutines until they are used rather than loading them all at once.\n\nTo use AutoLoader, the author of a module has to place the definitions of subroutines to be\nautoloaded after an \"END\" token.  (See perldata.)  The AutoSplit module can then be run\nmanually to extract the definitions into individual files auto/funcname.al.\n\nAutoLoader implements an AUTOLOAD subroutine.  When an undefined subroutine in is called in a\nclient module of AutoLoader, AutoLoader's AUTOLOAD subroutine attempts to locate the\nsubroutine in a file with a name related to the location of the file from which the client\nmodule was read.  As an example, if POSIX.pm is located in /usr/local/lib/perl5/POSIX.pm,\nAutoLoader will look for perl subroutines POSIX in /usr/local/lib/perl5/auto/POSIX/*.al,\nwhere the \".al\" file has the same name as the subroutine, sans package.  If such a file\nexists, AUTOLOAD will read and evaluate it, thus (presumably) defining the needed subroutine.\nAUTOLOAD will then \"goto\" the newly defined subroutine.\n\nOnce this process completes for a given function, it is defined, so future calls to the\nsubroutine will bypass the AUTOLOAD mechanism.\n",
                "subsections": [
                    {
                        "name": "Subroutine Stubs",
                        "content": "In order for object method lookup and/or prototype checking to operate correctly even when\nmethods have not yet been defined it is necessary to \"forward declare\" each subroutine (as in\n\"sub NAME;\").  See \"SYNOPSIS\" in perlsub.  Such forward declaration creates \"subroutine\nstubs\", which are place holders with no code.\n\nThe AutoSplit and AutoLoader modules automate the creation of forward declarations.  The\nAutoSplit module creates an 'index' file containing forward declarations of all the AutoSplit\nsubroutines.  When the AutoLoader module is 'use'd it loads these declarations into its\ncallers package.\n\nBecause of this mechanism it is important that AutoLoader is always \"use\"d and not\n\"require\"d.\n"
                    },
                    {
                        "name": "Using AutoLoader's AUTOLOAD Subroutine",
                        "content": "In order to use AutoLoader's AUTOLOAD subroutine you must explicitly import it:\n\nuse AutoLoader 'AUTOLOAD';\n"
                    },
                    {
                        "name": "Overriding AutoLoader's AUTOLOAD Subroutine",
                        "content": "Some modules, mainly extensions, provide their own AUTOLOAD subroutines.  They typically need\nto check for some special cases (such as constants) and then fallback to AutoLoader's\nAUTOLOAD for the rest.\n\nSuch modules should not import AutoLoader's AUTOLOAD subroutine.  Instead, they should define\ntheir own AUTOLOAD subroutines along these lines:\n\nuse AutoLoader;\nuse Carp;\n\nsub AUTOLOAD {\nmy $sub = $AUTOLOAD;\n(my $constname = $sub) =~ s/.*:://;\nmy $val = constant($constname, @ ? $[0] : 0);\nif ($! != 0) {\nif ($! =~ /Invalid/ || $!{EINVAL}) {\n$AutoLoader::AUTOLOAD = $sub;\ngoto &AutoLoader::AUTOLOAD;\n}\nelse {\ncroak \"Your vendor has not defined constant $constname\";\n}\n}\n*$sub = sub { $val }; # same as: eval \"sub $sub { $val }\";\ngoto &$sub;\n}\n\nIf any module's own AUTOLOAD subroutine has no need to fallback to the AutoLoader's AUTOLOAD\nsubroutine (because it doesn't have any AutoSplit subroutines), then that module should not\nuse AutoLoader at all.\n"
                    },
                    {
                        "name": "Package Lexicals",
                        "content": "Package lexicals declared with \"my\" in the main block of a package using AutoLoader will not\nbe visible to auto-loaded subroutines, due to the fact that the given scope ends at the\n\"END\" marker.  A module using such variables as package globals will not work properly\nunder the AutoLoader.\n\nThe \"vars\" pragma (see \"vars\" in perlmod) may be used in such situations as an alternative to\nexplicitly qualifying all globals with the package namespace.  Variables pre-declared with\nthis pragma will be visible to any autoloaded routines (but will not be invisible outside the\npackage, unfortunately).\n"
                    },
                    {
                        "name": "Not Using AutoLoader",
                        "content": "You can stop using AutoLoader by simply\n\nno AutoLoader;\n"
                    },
                    {
                        "name": "AutoLoader vs. SelfLoader",
                        "content": "The AutoLoader is similar in purpose to SelfLoader: both delay the loading of subroutines.\n\nSelfLoader uses the \"DATA\" marker rather than \"END\".  While this avoids the use of a\nhierarchy of disk files and the associated open/close for each routine loaded, SelfLoader\nsuffers a startup speed disadvantage in the one-time parsing of the lines after \"DATA\",\nafter which routines are cached.  SelfLoader can also handle multiple packages in a file.\n\nAutoLoader only reads code as it is requested, and in many cases should be faster, but\nrequires a mechanism like AutoSplit be used to create the individual files.\nExtUtils::MakeMaker will invoke AutoSplit automatically if AutoLoader is used in a module\nsource file.\n"
                    },
                    {
                        "name": "Forcing AutoLoader to Load a Function",
                        "content": "Sometimes, it can be necessary or useful to make sure that a certain function is fully loaded\nby AutoLoader. This is the case, for example, when you need to wrap a function to inject\ndebugging code. It is also helpful to force early loading of code before forking to make use\nof copy-on-write as much as possible.\n\nStarting with AutoLoader 5.73, you can call the \"AutoLoader::autoloadsub\" function with the\nfully-qualified name of the function to load from its .al file. The behaviour is exactly the\nsame as if you called the function, triggering the regular \"AUTOLOAD\" mechanism, but it does\nnot actually execute the autoloaded function.\n"
                    }
                ]
            },
            "CAVEATS": {
                "content": "AutoLoaders prior to Perl 5.002 had a slightly different interface.  Any old modules which\nuse AutoLoader should be changed to the new calling style.  Typically this just means\nchanging a require to a use, adding the explicit 'AUTOLOAD' import if needed, and removing\nAutoLoader from @ISA.\n\nOn systems with restrictions on file name length, the file corresponding to a subroutine may\nhave a shorter name that the routine itself.  This can lead to conflicting file names.  The\nAutoSplit package warns of these potential conflicts when used to split a module.\n\nAutoLoader may fail to find the autosplit files (or even find the wrong ones) in cases where\n@INC contains relative paths, and the program does \"chdir\".\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "SelfLoader - an autoloader that doesn't use external files.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "\"AutoLoader\" is maintained by the perl5-porters. Please direct any questions to the canonical\nmailing list. Anything that is applicable to the CPAN release can be sent to its maintainer,\nthough.\n\nAuthor and Maintainer: The Perl5-Porters <perl5-porters@perl.org>\n\nMaintainer of the CPAN release: Steffen Mueller <smueller@cpan.org>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This package has been part of the perl core since the first release of perl5. It has been\nreleased separately to CPAN so older installations can benefit from bug fixes.\n\nThis package has the same copyright and license as the perl core:\n\nCopyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,\n2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,\n2011, 2012, 2013\nby Larry Wall and others\n\nAll rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of either:\n\na) the GNU General Public License as published by the Free\nSoftware Foundation; either version 1, or (at your option) any\nlater version, or\n\nb) the \"Artistic License\" which comes with this Kit.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either\nthe GNU General Public License or the Artistic License for more details.\n\nYou should have received a copy of the Artistic License with this\nKit, in the file named \"Artistic\".  If not, I'll be glad to provide one.\n\nYou should also have received a copy of the GNU General Public License\nalong with this program in the file named \"Copying\". If not, write to the\nFree Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\nMA 02110-1301, USA or visit their web page on the internet at\nhttp://www.gnu.org/copyleft/gpl.html.\n\nFor those of you that choose to use the GNU General Public License,\nmy interpretation of the GNU General Public License is that no Perl\nscript falls under the terms of the GPL unless you explicitly put\nsaid script under the terms of the GPL yourself.  Furthermore, any\nobject code linked with perl does not automatically fall under the\nterms of the GPL, provided such object code only adds definitions\nof subroutines and variables, and does not otherwise impair the\nresulting interpreter from executing any standard Perl script.  I\nconsider linking in C subroutines in this manner to be the moral\nequivalent of defining subroutines in the Perl language itself.  You\nmay sell such an object file as proprietary provided that you provide\nor offer to provide the Perl source, as specified by the GNU General\nPublic License.  (This is merely an alternate way of specifying input\nto the program.)  You may also sell a binary produced by the dumping of\na running Perl script that belongs to you, provided that you provide or\noffer to provide the Perl source as specified by the GPL.  (The\nfact that a Perl interpreter and your code are in the same binary file\nis, in this case, a form of mere aggregation.)  This is my interpretation\nof the GPL.  If you still have concerns or difficulties understanding\nmy intent, feel free to contact me.  Of course, the Artistic License\nspells all this out for your protection, so you may prefer to use that.\n\n\n\nperl v5.34.0                                 2025-07-25                            AutoLoader(3perl)",
                "subsections": []
            }
        }
    }
}