If you're in a hurry, just run these and you're done.
Now start a new shell, and you're done.curl -L http://cpanmin.us | perl - --self-upgrade ~/perl5/bin/cpanm local::lib perl -I ~/perl5/lib/perl5 -Mlocal::lib >> ~/.bashrc
Full instructions...
Firstly, you need perl installed on your machine. I'm not covering that here, there are lots of good guides. If you're on Ubuntu, Debian, or anything based off Debian, it's just sudo apt-get install perl.
Installing cpanm
First, grab cpanm from the web:
If you don't have curl, then:curl -L http://cpanmin.us | perl - --self-upgrade
And if you don't have either, just go to http://cpanmin.us/, right click, and save the source as cpanm. Then run perl cpanm --self-upgrade.wget -O - http://cpanmin.us | perl - --self-upgrade
Installing local::lib
cpanm will install itself in ~/perl5/bin/cpanm by default. It'll also install new modules and supporting files into ~/perl5 . However you probably don't have these in your path. While you can set things up manually, it's much easier to install local::lib. We can do that with:
Now we can use local::lib to set up our environment variables. If you want, you can run perl -I ~/perl5/lib/perl5/ -Mlocal::lib to print them. Here's what mine look like:~/perl5/bin/cpanm local::lib
You could run these, but it's way easier to just add the appropriate command to your .bashrc file and never worry about it again. Assuming you're using bash as your shell:export PERL_LOCAL_LIB_ROOT="/home/pjf/perl5"; export PERL_MB_OPT="--install_base /home/pjf/perl5"; export PERL_MM_OPT="INSTALL_BASE=/home/pjf/perl5"; export PERL5LIB="/home/pjf/perl5/lib/perl5/i686-linux-gnu-thread-multi-64int:/home/pjf/perl5/lib/perl5:$PERL5LIB"; export PATH="/home/pjf/perl5/bin:$PATH";
Now start a new shell, and you'll have access to cpanm, all Perl programs will be able to find the modules you install (there's no need for root access), and you'll be able to install new things from the cpan with cpanm Module::Name.perl -I ~/perl5/lib/perl5 -Mlocal::lib >> ~/.bashrc
Congratulations!
No comments:
Post a Comment