The easiest way to install CPAN modules in perl is using cpanm which, furthermore, allows you to install modules without requiring root access.
In OS X, look into your
~/.bash_profile and remove any references that you might already have to the
PERL5LIB environment variable. Then run the following commands on a terminal:
$ curl -L http://cpanmin.us | perl - -l ~/Library/perl5 App::cpanminus local::lib
$ eval `perl -I ~/Library/perl5/lib/perl5 -Mlocal::lib=~/Library/perl5`
$ echo 'eval `perl -I ~/Library/perl5/lib/perl5 -Mlocal::lib=~/Library/perl5`' >> ~/.bash_profile
If everything went right, now you can install packages using:
$ cpanm Some::Package
Some more details and a detailed explanation on this question can be found at using CPAN as non-root user on Stack Overflow.
Hopefully your package is now installed and you can enjoy life.
Ok, for some reason the installation above didn’t work and you are still reading this. You might want to try installing your module using either CPANPLUS, by typing:
$ cpanp -i Some::Module
or the more traditional CPAN
$ cpan Some::Module
If even that fails, try to looking at the produced output and install any dependencies or outdated packages first. Then retry.
You are still reading so I guess nothing has worked so far. You probably need to do a manual install. In particular you may need a manual install if you get the “Sorry, PREFIX is not supported” error when trying to use
cpan to install a package which has been built using Module::Build. Go figure.
So, look up the download url for the
.tar.gz package on CPAN and then type
$ wget http://search.cpan.org/url/to/Some-Module.tar.gz
$ tar -zxvf Some-Module.tar.gz
% cd Some-Module/
If you see a
Build.PL file then do
$ perl Build.PL # if dependencies or module updates are needed do those first!
$ ./Build test
$ ./Build install --install_base ~/perl5lib
$ perl Makefile.PL # if dependencies or module updates are needed do those first!
$ make test
$ make install PREFIX=~/perl5lib
PREFIX options are only needed if you are running a non-root installation, and it should point to the proper location in your home directory. Otherwise you need to
sudo that last command to do a root install.
Yeah. Life is hard.