Perl

Installing modules locally
As per river on toolserver-l, it is best to just fill in a bugreport at JIRA project TS to have modules installed server-wide for everyone.

Otherwise, if there is some good reason you can install them for yourself under your home directory with cpanminus. Note that if you install Perl modules this way, they will not be automatically upgraded by system administrators. This means, for example, if you locally install a Perl module that uses XS, then the system Perl itself is upgraded to a new major version (5.14 coming up in 2011), Perl will crash out when attempting to load the now incompatible module.

Step 1: Add these lines to your ~/.bash_profile: export PATH=$PATH:~/bin export PERL5LIB=$PERL5LIB:~/lib/perl5 export MANPATH=$MANPATH:~/man and change the following two values in your ~/.cpan/CPAN/MyConfig.pm 'make' => q[make], 'make_install_make_command' => q[make],

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

These steps need to be done only once.

From then on, install the module(s) you want by running the following command on a Solaris host:

$ cpanm -l ~ Chocolate::Belgian Foo::Bar

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

use lib '/home/username/lib/perl5';

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.