I tried
BEGIN {
unshift @INC, 'current_path_string';
}
But it only works for us开发者_如何学Ce
, when require
, it's not searched.
Is there a work around?
When running under mod_perl, once the server is up @INC
is frozen and cannot be updated. The only opportunity to temporarily modify @INC
is while the script or the module are loaded and compiled for the first time. After that its value is reset to the original one. The only way to change @INC
permanently is to modify it at Apache startup.
Two ways to alter @INC
at server startup:
In the configuration file. e.g
PerlSetEnv PERL5LIB /home/httpd/perl
In the startup file directly alter the
@INC
and load the startup file from the configuration file.
See also @INC and mod_perl
Yes, you can update @INC in the startup script. But using the code below in your module will simply work:
use lib '/app/my-libs';
at least - for my CGI app running under mod_perl.
use Foo;
is the same as
BEGIN {
require Foo;
import Foo;
}
so if it works for use
, it works for require
.
精彩评论