in reply to Require Load Times
As you can see defenitions of subroutines are put into a hash as strings. When Perl parses such code it does it very quickly since it doesn't have to parse actual subroutine code.%SUBS = ( ... ... ... 'some_sub1' => <<'END_OF_FUNC', sub some_sub1 { ... ... } END_OF_FUNC 'some_sub2' => <<'END_OF_FUNC', sub some_sub2 { ... ... } END_OF_FUNC ... ... ... )
CGI.pm uses AUTOLOAD to detect undefined subroutine calls and to evaluate subroutines code on fly when they are used.
Update: You can use autoloading techiques yourself for your modules. Probably you don't need to roll your own code for autoloading like CGI.pm does. Use one of these modules: AutoLoader, SelfLoader and autouse.
--
Ilya Martynov
(http://martynov.org/)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Require Load Times
by ehdonhon (Curate) on Dec 30, 2001 at 10:26 UTC | |
by chromatic (Archbishop) on Dec 30, 2001 at 11:16 UTC |