Recently I had to debug a perl-based website (don’t ask). In getting my PC set up to do this, I realized that things have changed in the past 8 years – the last time I was forced to do lucky enough to have the opportunity to do any perl development. These were the steps:
- WAMP no longer ships with mod_perl apparently. It was definitely available as an add-on for a previous version, but I guess no longer. So as per this blog post, download and install ActivePerl.
- That gets installed to C:\Perl\bin so with each of your scripts you’ll have to change the path to perl in the header of each of your perl scripts.
- In your httpd.conf, make sure you have added the “.pl” ScriptHandler and enabled ExecCGI in the appropriate directory if your scripts are outside /cgi-bin/.
... AddHandler cgi-script .cgi .pl ... <Directory /> AllowOverride All Options FollowSymLinks ExecCGI Order allow,deny Allow from all </Directory>
- Your life will be a lot easier if you output the errors to your browser rather than sifting through the Apache log, so I used this everywhere:
#!C:/Perl/bin/perl.exe -w use strict; use CGI; use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
- You may have to install other CPAN modules to get real-life scripts working. The shell is located in C:\Perl\bin as well.
- You might need to connect to the WAMP database. I could only get this to work by installing the DBD-MySQL PPD from outside the ActiveState repository. So run
C:\Perl\bin\ppm install http://cpan.uwinnipeg.ca/PPMPackages/10xx/DBD-mysql.ppd
Then you can access your DB via:
#!C:/Perl/bin/perl.exe -w use strict; use CGI; use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; my $DSN = "dbi:mysql:database=dbname;host=localhost;port=3306"; my $dbh = DBI->connect($DSN, "root", "", {RaiseError=>1}); print "// CONNECT ERROR: ".$DBI::errstr."\n"; ...
Enjoy.