Some Perl modules, such as DBI, need to be downloaded, compiled and installed.
I’m connecting to a remote production testing computer, for which I have only my local user password (no root, for obvious reasons). I’ve used wget to download some external modules that I need, such as DBI, and unpacked these resulting in directories like ~/modules/DBI-<version>.
Normally, when compiling something for Linux, you run configure to pre-configure everything before installation; and one of its switches is --prefix=<some_dir>, which controls where the compiled executable and all compiled dependencies will ultimately end up.
But for Perl modules, you don’t run configure, so my first question is:
- Can I control where the compiled modules (e.g.
DBI.pm) go when I runmake? If so, how?
Failing that, I at least need to update @INC, so I can refer to the module; so my second question is:
- How can I find out where the compiled modules went when I ran
make?
I can’t issue make install after compiling, and moreover, I’ve been asked not to. (I’ve been asked to design the script so that it doesn’t rely on external modules being in the standard system path.)
The installation directory is set when the makefile for the module is built. Each module comes with a
Makefile.PLwhich must be run to build the makefile, taking into account the current Perl configuration.Makefile.PLhas the optionPREFIXthat says where the build is going to be installed, so after unpacking the module’s distribution andcding to the unpacked directory you can sayThis process is described in the Perl documentation – read
perldoc perlmodinstall. You could go into the CPAN shell and use the ‘o’ (lower-case) oprion that allows you to change the options passed tomakefile.PL, but I think the manual build/test/install is more straightforward and gives you more control over the process.Remember to add
to the start of your program to make sure Perl searches the new directory for modules.