use Devel::SelfStubber; $modulename = "Mystuff::Grok"; # no .pm suffix or slashes $lib_dir = ""; # defaults to current directory Devel::SelfStubber->stub($modulename, $lib_dir); # stubs only # to generate the whole module with stubs inserted correctly use Devel::SelfStubber; $Devel::SelfStubber::JUST_STUBS = 0; Devel::SelfStubber->stub($modulename, $lib_dir);
The stub ensures that if a method is called, it will get loaded. This is best explained using the following example:
Assume four classes, A, B, C, and D. A is the root class, B is a subclass of A, C is a subclass of B, and D is another subclass of A.
A / \ B D / C
If D calls an autoloaded method
So, to get autoloading to work right with classes and subclasses, you need to make sure the stubs are loaded.
But you may wish to avoid having the stub-loading overhead associated
with your initialization.[
In this case, you can put the subroutine stubs before the
At the very least, this module is useful for seeing what the SelfLoader thinks are stubs; in order to ensure that future versions of the SelfStubber remain in step with the SelfLoader, the SelfStubber actually uses the SelfLoader to determine which stubs are needed.