ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы.



Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: 8.2 attrsChapter 8
Standard Modules
Next: 8.4 AutoSplit
 

8.3 AutoLoader

Delays the loading of functions until they are used. Each function is placed in a file that has the same name as the function, with an .al extension. The files are stored in a subdirectory of the auto/ directory that is named after the package. For example, the function GoodStuff::whatever is loaded from the file auto/GoodStuff/whatever.al. Should always be used and not required.

A module using the AutoLoader has the special marker __END__ prior to the declarations for the subroutine to be autoloaded. Any code before this marker is loaded and compiled when the module is used, but at the marker, Perl stops parsing the file.

Later, during execution, when a subroutine that isn't yet in memory is called, the AUTOLOAD function attempts to find it in a directory relative to the location of the module file. For example, if POSIX.pm is in the directory /usr/local/lib/perl5, then the AutoLoader looks for POSIX subroutines in /usr/local/lib/perl5/auto/POSIX/*.al.


Previous: 8.2 attrsPerl in a NutshellNext: 8.4 AutoSplit
8.2 attrsBook Index8.4 AutoSplit