At 02:37 PM 8/19/02 -0700, Randy J. Ray wrote: >> use AutoLoader 'preload'; # preload anything you can find in %INC >> use AutoLoader preload => { module => '' }; # all from specific module >> use AutoLoader preload => { module => [qw(suba subb)] }; # only specific >>Would that make sense? >Problem with that approach is that it doesn't offer any control over whether >you are pre-loading or not. If you are going to pre-load a certain sub-set of >routines all the time, just put them above the __END__ token and don't burden >AutoLoader with new functionality at all.
Well, my C<use AutoLoader> would be _outside_ any of the loaded modules in the mod_perl startup.pl script after all the modules necessary for proper execution of _your_ mod_perl environment, are loaded. >What I was suggesting was a way that I, as the writer of (picking one of my >own modules as an example) RPC::XML::Server can incorporate something in the >compile-time logic so that Apache::RPC::Server contains: > use RPC::XML::Server 'compile'; >And RPC::XML::Server can have: >sub import { > AutoLoader::preload(__PACKAGE__, @list_o_routines) > if (lc $_[1] eq 'compile'); >} >(Admittedly a simplistic example, but I hope it gets the point across) That also makes sense, but wasn't my original idea. I'd rather make this a class method, so: AutoLoader->preload( @list_o_routines ); and have the module derive the module name from caller(). That would at least simplify the call and it would reduce the risk of abuse. >This way, I only pre-load routines in the cases where I need it done. Your >suggestion is good for modules that are only ever used under mod_perl, but >modules may be designed to work in other environments. Oh, you could manage >to get the same affect as my idea using a BEGIN block and conditional calls >of "use AutoLoader", but the above seems to me to be much cleaner. I'm more interested in the modules that either work in a mod_perl environment and a "normal" Perl environment. If a module is supposed to be used in mod_perl, it just shouldn't use AutoLoader. Liz