====== CPAN ====== If you need a **[[shared:kb:perl|Perl module]]** that is not currently installed, and especially if you need a Perl module that can't be installed by pkgsrc (the "3rd party packaging system" used on Shared Accelerators) then you can set up CPAN to automate the installation of modules. These instructions are based on [[http://sial.org/howto/perl/life-with-cpan/non-root/|these at sial.org]]. ==== Step 1 ==== Make your own CPAN directory, and the directory your modules will be stored in: $ mkdir -p ~/.cpan/CPAN $ mkdir -p ~/lib/perl5 ==== Step 2 ==== Download [[http://sial.org/howto/perl/life-with-cpan/MyConfig.pm|this Config.pm file at sial.org]] and put it into the CPAN directory you just made, so it's at ~/.cpan/CPAN/MyConfig.pm ==== Step 3 ==== In the MyConfig.pm file change all occurrences of **HOMEDIRFIX** to **/users/home/yourusername** (using YOUR username of course). ==== Step 4 ==== In MyConfig.pm change **/usr/bin/wget** to **/usr/sfw/bin/wget**. ==== Step 5 ==== Test that MyConfig.pm's syntax is OK: $ perl -c ~/.cpan/CPAN/MyConfig.pm MyConfig.pm syntax OK ==== Step 6 ==== Add the following to your ~/.bash_profile file (if you don't have one, create an empty text file with that name and put this in it): if [ -d $HOME/lib/perl5 ]; then PERL5LIB=${PERL5LIB:+$PERL5LIB:}$HOME/lib/perl5 fi export PERL5LIB ==== Step 7 ==== Log out and back in again for the above to take effect (is there a way to do this without logging out and in?). ==== Step 8 ==== That's it! You should now be able to install Perl modules using CPAN. Here's how you'd install Config::Simple for example: $ cpan cpan> install Config::Simple ... /usr/bin/make install -- OK cpan> exit $ ==== Step 9 ==== OK, not quite done. This will work for perl scripts you run on the command line; the lines we added to your .bash_profile tells our scripts where to find the new modules. For any scripts you run another way, such as via cron, you'll need to add a line before "use"ing any of your modules: #!/usr/bin/perl use lib "/users/home/yourusername/lib/perl5"; use Config::Simple; Again, of course, replacing **yourusername** with your own.