[Moscow.pm] Кто как работает с INC
Peter Vereshagin
peter на vereshagin.org
Пн Ноя 15 11:18:35 PST 2010
I'm face to face with moscow-pm who sold the world?
2010/11/15 09:33:01 -0800 moscow-pm-request на pm.org => To moscow-pm на pm.org :
> use FindBin;
> use lib "$FindBin::Bin/../lib";
> > В больших проектах что-то в этом роде
> > export PERL5LIB=$ROOT_PRJ/lib:$PERL5LIB
> >
> > в отдельных скриптах
> > use lib qw(lib);
> > Кстати, не push @INC, а
> > BEGIN {
> > push @INC # а лучше unshift
> > }
> >> use lib::abs ftw!
package somepkg;
(...)
our $somepkg_lib;
BEGIN{
use Cwd qw/realpath getcwd/;
use File::Basename qw/dirname/;
$somepkg_lib = realpath( dirname( __FILE__ )."/../lib" );
unshift( @INC, $somepkg_lib ) unless grep { $_ eq $somepkg_lib } @INC;
}
По-хорошему бы туда такие юзлибы:
=== perlrun ===
Perl can be built so that it by default will try to execute
$Config{sitelib}/sitecustomize.pl at startup (in a BEGIN block).
This is a hook that allows the sysadmin to customize how perl
behaves. It can for instance be used to add entries to the @INC
array to make perl find modules in non-standard locations.
Perl actually inserts the following code:
BEGIN {
do { local $!; -f "$Config{sitelib}/sitecustomize.pl"; }
&& do "$Config{sitelib}/sitecustomize.pl";
}
===
но это не всегда возможно/удобно/нужно
73! Peter pgp: A0E26627 (4A42 6841 2871 5EA7 52AB 12F8 0CE1 4AAC A0E2 6627)
--
http://vereshagin.org
Подробная информация о списке рассылки Moscow-pm