Is there a way to avoid putting the Perl version number into the “use lib” line for Perl modules in non-standard locations?

我们两清 提交于 2019-12-06 06:35:46

问题


I am trying to install some Perl modules into a non-standard location, let's call it /non/standard/location. I used

perl Makefile.PL PREFIX=/non/standard/location
make;make install

to install them.

In the script which uses the module, it seems to be necessary to specify a long directory path including the version of Perl, like so:

#!/usr/local/bin/perl
use lib '/non/standard/location/lib/perl5/site_perl/5.8.9/';
use A::B;

Is there any use lib or other statement which I can use which is not so long and verbose, and which does not include the actual version of Perl, in order that I don't have to go back and edit this out of the program if the version of Perl is upgraded?


回答1:


Probably not addressing all your questions, but do you know local::lib? When it’s available in the system perl, you can just use local::lib. If not:

use lib glob '~/perl5/lib/perl5';
use local::lib;

That’s probably a bit constraining – not sure how it works on Windows –, but it’s good enough for my purposes. Of course, if you can set up the environment before the script runs (.bashrc, SetEnv etc.), you can forget about the use lib glob, as the right path will be already set in PERL5LIB.




回答2:


Currently I have installed via the following prescription, which seems to fix things.

perl Makefile.PL --no-manpages --skipdeps PREFIX=/non/system/location INSTALLSITELIB=/non/system/location/lib INSTALLSITEBIN=/non/system/location/bin INSTALLMAN1DIR=/non/system/location/man/man1 INSTALLMAN3DIR=/non/system/location/man/man3

I welcome any constructive criticism of this. I want to use --no-manpages but the INSTALLMAN1DIR seems to be necessary anyway.



来源:https://stackoverflow.com/questions/3067011/is-there-a-way-to-avoid-putting-the-perl-version-number-into-the-use-lib-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!