Toolserver:Perl

Installing modules locally
Instead of bugging River for adding perl modules, you can install them for yourself into your home directory. While these instructions only work for installing modules from nightshade, if the module is pure perl it can still be used on willow.

Note that if you install Perl modules this way, they will not be automatically upgraded by system administrators. This means, for example, if you install a Perl module that uses XS locally, then Perl itself is upgraded, you could have problems with your modules (such as odd bugs, or crashes of Perl itself).

Step 1: Add these lines to your ~/.bash_profile: export PERL5LIB=$PERL5LIB:~/lib export MANPATH=$MANPATH:~/man

Step 2: You will need to create some directories $ mkdir -p ~/bin $ mkdir -p ~/lib $ mkdir -p ~/man/man{1,3} $ mkdir -p ~/.cpan/CPAN $ mkdir -p ~/.cpan/build $ mkdir -p ~/.cpan/sources

Step 3: You'll need to copy the global CPAN settings (/etc/perl/CPAN/Config.pm) file (from wolfsbane!) to ~/.cpan/CPAN/MyConfig.pm: $ cp /etc/perl/CPAN/Config.pm ~/.cpan/CPAN/MyConfig.pm

Step 4: Edit MyConfig.pm

Step 4a: Replace every reference to the /home/simetrical/ directory to your home directory.

Step 4b: Change the 'makepl_arg' setting to this: LIB=~/lib INSTALLSITEMAN1DIR=~/man/man1 INSTALLSITEMAN3DIR=~/man/man3

Step 5: Save, logout, then log back in, so the new environment variables are set.

Step 6: Start CPAN: $ perl -MCPAN -e "shell"

Step 7: Install modules. The .pm files are added to your ~/lib directory, and the documentation is added to your ~/man directory. For example: cpan> install Text::CSV

Step 8: There is no step 8. You're done!

If you use CGI scripts in perl you have to add your home directory to @INC because CGI scripts do not parse your ~/.bash_profile:

use lib "/home/username/lib";

FastCGI
The following code shows how to create PERL scripts that use FastCGI via the CGI::Fast module.

Note that although CGI::Fast is installed on the web server, it may not be installed on the toolserver login servers. It is available from CPAN.

The code above ignores the main benefit of FastCGI, which is that a single instance of the script can serve multiple web requests. The following code demonstrates how to achieve this.

Miscellany

 * Why do I get an error 500 if I try to run my Perl CGI script?
 * Use the short checklist or the long checklist to find the answer.


 * I need the perl module FOO::Bar. How do I install it?
 * Just fill in a bugreport at JIRA. Otherwise, if there is some good reason to install it locally, use the following instructions: Installing perl modules into your $HOME