ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
7.2.9 Devel::SelfStubber - Generate Stubs for a SelfLoading Moduleuse 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); Devel::SelfStubber supports inherited, autoloaded methods by printing the stubs
you need to put in your module before the
sub moo; 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. The SelfLoader can load stubs automatically at module initialization with: SelfLoader->load_stubs(); But you may wish to avoid having the stub-loading overhead associated
with your initialization.[8]
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. |