in reply to Using CPAN to install modules in $HOME?

Yes, you can do this by creating a file named $HOME/.cpan/CPAN/MyConfig.pm In that file, you can specify custom arguments to be added any time that a Makefille.PL is run. By specifying a LIB= or PREFIX= argument, you can make the CPAN module install the lib any place you want. It would look something like this:

$CPAN::Config->{makepl_arg} = q[ PREFIX=DIRECTORY_NAME ];

Or, if you are working with the interactive shell, you can just skip the config file, and do this from the shell:

o conf makepl_arg PREFIX=DIRECTORY_NAME
(where DIRECTORY_NAME is the name of the directory you wish to install to).

Good luck!

Replies are listed 'Best First'.
Re: Re: Using CPAN to install modules in $HOME?
by bnanaboy (Beadle) on Oct 31, 2002 at 14:16 UTC
    Being a non-root user I have tried doing this (installing modules into a directory for which I have write permission), and then adding the directory into @INC with

    use lib '/path/to/my/dir';

    but this doesn't work with modules for which an older version exists. Perl uses the older version (DBI v1.13 instead of DBI v1.30). Is there a way I can specify the version/location I want used instead of letting Perl pick the one it likes? Or, I guess more specifically, can I specify explicitly the order in which directories containing libraries should be considered for inclusion.

    UPDATE: Just in case anyone else should ever have this problem, I found out there are multiple instances of perl installed on our system. The default instance called when I ran  perl Makefile.pl  is in a different location than the one I specified in my script. It solved the problem to re-install the module using  /path/to/perl Makefile.pl  when compiling the module.

      Perl should always search for libraries in your directories in the order that they appear in @INC. If '/path/to/my/dir' is the first thing in @INC, perl will look there first.

      You might want to try something like this:

      #!/usr/bin/perl use lib '/path/to/my/dir'; use DBI; use Data::Dumper; print Dumper( \@INC, \%INC );

      That will tell you exactly what is in your @INC, and exactly where Perl is finding all its libraries.