views:

66

answers:

2

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?

+5  A: 

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.

zoul
I've just found it in fact; looks like a good solution.
Kinopiko
+1: I didn't know you could `use lib glob`. No more manually resolving `~` to an actual path!
Dave Sherohman
A: 

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.

Kinopiko