Troubleshooting common Perl issues
Here are some common problems and solutions you may find useful once you start scripting with Perl.
Plain text Perl source code is displayed
If your web browser simply displays the source code of your CGI script this indicates that the webserver didn’t know how to process it. The most common causes are incorrect file permissions (see below) or that the script is not in the cgi-bin folder.
The top cause of this error is incorrect permissions on a script or directory. Directories that contain web content (including cgi scripts) must be mode 755. CGI scripts must also be 755.
Invalid script interpreter
The script interpreter is defined on the first line of the script after the #! and must exist on the server. This is usually perl and needs to be ‘/usr/bin/perl’. These paths can vary from system to system and it’s important to ensure that they’re correct for this server.
Script uploaded in binary mode
Text files are slightly different between Unix and Windows platforms. If you upload in ASCII mode, the FTP server will translate the files to Unix mode for you if necessary. If you upload in binary mode, it won’t. CGI scripts are one of the few places on web servers where this difference actually matters.
Script did not output headers
CGI scripts must output HTTP headers. If you’re using Perl, you must do it yourself or use a helper module to do it for you. You must also ensure that the headers are always the first output generated by the script. It’s not uncommon for test or debugging code to output a message before the headers and that will cause the server to treat the script as broken.
Syntax error in script
This error will be generated if scripts have syntax errors and don’t actually run successfully. You should obtain the relevant interpreter for your script and try to run it before uploading as this is the easiest way to ensure that there are no syntax errors.
Script is trying to use a module not installed on the server
Perl scripts will usually die with an error if a module the script requires is not installed. If you suspect a module you require is not installed, please contact our Support Team.
What to do if all else fails
If you’ve checked all of these things and can’t fix the problem, our Support staff will be able to assist in finding out more specific details of the actual problem and provide more detailed information or sources on how to resolve it.