Nowadays, a setup like this would be a mere historical curiosity, but the reason this came up is because I'm teaching a class on open source technologies at Ateneo de Davao. I gave my students a set of exercises on Perl. Nothing fancy, just connect to a database and print something out. Then the thought came to mind: as an extra challenge, how about I also include web output.
Easier said than done, apparently. There is the
libapache2-mod-perl2module, but once you get that installed, what do you do next? Some minor Apache surgery is still required.
First, you need to add the following lines to
AddHandler cgi-script .pl
<Files ~ "\.pl$">
This tells Apache that anything with the
.plextension has to be treated as a CGI script.
Then, restart the Apache web server.
As an additional caveat, any Perl script that generates a web page must always send out the right headers. Otherwise an Internal Server Error will occur. Actually, it's really as simple as adding the following lines before sending out any other data.
print "Content-type: text/html\n\n";
The script must also be marked executable.