Yeah but that doesn't help him entirely with a solution to his problem -- 
which is that he wants to load something at runtime later on -- not at 
compile time.

And in fact, it is a must to be able to do this in some cases. eg he 
correctly points out that LWP uses the factory design pattern to load 
modules dynamically rather than at compile time. I use this technique all 
over the stuff I write because it conveniently defers the decision of what 
to load --

Of course, if it is loaded ahead of time using PerlRequire then there isn't 
any problem... and you get enhanced performance, but it is also a pain to 
know all the modules and submodules you want to load ahead of time.

CAVEAT ALERT: Then the only caveat is namespace problems if there is more 
than one local copy of a module...

however, given that caveat in mind, the following code should work well:

use lib qw(./Modules);
use vars qw(@SAVED_INC);

BEGIN {
   @SAVED_INC = @INC;
}

@INC = @SAVED_INC;

In the header of the relevant scripts.

Later,
    Gunther


At 11:36 PM 5/13/00 +0300, Stas Bekman wrote:
>On Sat, 13 May 2000, Robert Nice wrote:
>
> > Hi,
> >
> > Simple problem, I had a quick search thorugh the archives and a good
> > delve into the perl website, no joy.
>
>You didn't delve deep enough, perl.apache.org/index.html reveals no
>mod_perl specific info.
>
>Guide is your guide into mod_perl. The answer to your question is there:
>http://perl.apache.org/guide/porting.html#_INC_and_mod_perl
>
> > (Using modPerl 1.23)
> >
> > #!/usr/bin/perl -w
> >
> > use lib '../site_perl';
> > use CGI;
> >
> > my $cgi = new CGI;
> > print $cgi->header;
> > print join("<br>\n", @INC);
> > -----------------------------------------------------------
> > First time (compiling run):
> > ../site_perl
> > /usr/lib/perl5/5.00503/i386-linux
> > /usr/lib/perl5/5.00503
> > /usr/lib/perl5/site_perl/5.005/i386-linux
> > /usr/lib/perl5/site_perl/5.005
> > .
> > /etc/httpd/
> > /etc/httpd/lib/perl
> > ------------------------------------------------------------
> > Second run :
> > /usr/lib/perl5/5.00503/i386-linux
> > /usr/lib/perl5/5.00503
> > /usr/lib/perl5/site_perl/5.005/i386-linux
> > /usr/lib/perl5/site_perl/5.005
> > .
> > /etc/httpd/
> > /etc/httpd/lib/perl
> > -----------------------------------------------------------
> >
> > In other words my 'use lib' line disappears. I can understand why. You 
> typically won't need it after
> > it's already been compiled. I've been happily using modPerl for ages 
> and this
> > hasn't caused a problem. My company however newly requires that I speak 
> to 25 different credit card
> > processors and I wanted to pull them in with 'eval "require 
> $classname"' statements like LWP does
> > with net protocols. For efficency
> > I'd like to compile them when needed not in bulk on the first run.
> > I'd also prefer not to put my libraries in the system library area as 
> it defeats my development
> > setup of having test and beta libraries on the same machine.
> > I've got a workaround (I force them all to load on the first run if 
> under modPerl), however I
> > thought I'd post, might be something for the developers to think about.
> >
> > Cheers,
> >
> > Robert Nice
> > Technical Director
> > WebsiteBilling.com Inc
> >
>
>
>
>_____________________________________________________________________
>Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
>http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
>mailto:[EMAIL PROTECTED]   http://perl.org     http://stason.org/TULARC
>http://singlesheaven.com http://perlmonth.com http://sourcegarden.org

__________________________________________________
Gunther Birznieks ([EMAIL PROTECTED])
Extropia - The Web Technology Company
http://www.extropia.com/

Reply via email to