in reply to Cost of passing function references
Your reviewer is misinformed.
Perl code compiles as it is loaded. By the time the first executable line of code in a Perl program is run, the whole program has already been compiled.
Exceptions:
Code inside BEGIN blocks is run as soon as the enclosing block has been compiled.
Code inside modules included by use is run as soon as the module has been compiled. (use is run as soon as it compiled.)
Code inside modules included by require is not compiled until the require is executed.
Code inside files included by do is not compiled until the do is executed.
Code contained in strings is not compiled until evaluated by eval.
Subroutines loaded by the AUTOLOAD mechanism won't be compiled until your program calls them.
FYI, there are modules to facilitate autoloading, including AutoLoader and SelfLoader.
Update: Clarified use and added mention of do.
|
|---|