{
    "mode": "perldoc",
    "parameter": "Devel::SelfStubber",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Devel%3A%3ASelfStubber/json",
    "generated": "2026-06-14T00:22:09Z",
    "synopsis": "To generate just the stubs:\nuse Devel::SelfStubber;\nDevel::SelfStubber->stub('MODULENAME','MYLIBDIR');\nor to generate the whole module with stubs inserted correctly\nuse Devel::SelfStubber;\n$Devel::SelfStubber::JUSTSTUBS=0;\nDevel::SelfStubber->stub('MODULENAME','MYLIBDIR');\nMODULENAME is the Perl module name, e.g. Devel::SelfStubber, NOT 'Devel/SelfStubber' or\n'Devel/SelfStubber.pm'.\nMYLIBDIR defaults to '.' if not present.",
    "sections": {
        "NAME": {
            "content": "Devel::SelfStubber - generate stubs for a SelfLoading module\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "To generate just the stubs:\n\nuse Devel::SelfStubber;\nDevel::SelfStubber->stub('MODULENAME','MYLIBDIR');\n\nor to generate the whole module with stubs inserted correctly\n\nuse Devel::SelfStubber;\n$Devel::SelfStubber::JUSTSTUBS=0;\nDevel::SelfStubber->stub('MODULENAME','MYLIBDIR');\n\nMODULENAME is the Perl module name, e.g. Devel::SelfStubber, NOT 'Devel/SelfStubber' or\n'Devel/SelfStubber.pm'.\n\nMYLIBDIR defaults to '.' if not present.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Devel::SelfStubber prints the stubs you need to put in the module before the DATA token (or\nyou can get it to print the entire module with stubs correctly placed). The stubs ensure that if\na method is called, it will get loaded. They are needed specifically for inherited autoloaded\nmethods.\n\nThis is best explained using the following example:\n\nAssume four classes, A,B,C & D.\n\nA is the root class, B is a subclass of A, C is a subclass of B, and D is another subclass of A.\n\nA\n/ \\\nB   D\n/\nC\n\nIf D calls an autoloaded method 'foo' which is defined in class A, then the method is loaded\ninto class A, then executed. If C then calls method 'foo', and that method was reimplemented in\nclass B, but set to be autoloaded, then the lookup mechanism never gets to the AUTOLOAD\nmechanism in B because it first finds the method already loaded in A, and so erroneously uses\nthat. If the method foo had been stubbed in B, then the lookup mechanism would have found the\nstub, and correctly loaded and used the sub from B.\n\nSo, for classes and subclasses to have inheritance correctly work with autoloading, you need to\nensure stubs are loaded.\n\nThe SelfLoader can load stubs automatically at module initialization with the statement\n'SelfLoader->loadstubs()';, but you may wish to avoid having the stub loading overhead\nassociated with your initialization (though note that the SelfLoader::loadstubs method will be\ncalled sooner or later - at latest when the first sub is being autoloaded). In this case, you\ncan put the sub stubs before the DATA token. This can be done manually, but this module\nallows automatic generation of the stubs.\n\nBy default it just prints the stubs, but you can set the global $Devel::SelfStubber::JUSTSTUBS\nto 0 and it will print out the entire module with the stubs positioned correctly.\n\nAt the very least, this is useful to see what the SelfLoader thinks are stubs - in order to\nensure future versions of the SelfStubber remain in step with the SelfLoader, the SelfStubber\nactually uses the SelfLoader to determine which stubs are needed.\n",
            "subsections": []
        }
    },
    "summary": "Devel::SelfStubber - generate stubs for a SelfLoading module",
    "flags": [],
    "examples": [],
    "see_also": []
}