The "500 Internal Server Error" is likely to be the most common error message you will see while debugging your scripts. Unfortunately, it is also a very generalized error message, which reveals little other than that there is some problem with the script.
To locate the problem or problems, a systematic approach is needed. First and foremost, you should take care to always do the following: If you are uploading the script to your server via FTP, always make sure you have done so in ASCII format.
If your FTP client autodetects, make sure it knows that .cgi and .pl files are ASCII files. Uploading in BINARY format will cause problems.
Make sure the first line of your script is the path to Perl, and that it is correct.
It should look like:
#!/bin/perl
which is the path to Perl 5.
If you are still getting the 500 error you can get the web server to send the reason for the error to your browser by using the CGI::Carp module.
Enter the line:
use CGI::Carp qw(fatalsToBrowser);
after the #!/bin/perl line.
When the script encounters an error, you will get a message like,
"Software error: Error description at .script.pl line 6."
which will give you the location of the line containing the error.
Other points
When debugging a program you will generally need to place print statements in strategic locations, to see how the flow of the program is working. You might add one inside an if/then statement for instance, so that you can see if the statement is being evaluated as true or false.
Problems sending email from scripts
If your cgi scripts need to send email from the server they need to be configured to use the Easyspace mail program 'easymail'. The reason for this is that we do not support direct sendmail access.
This means that where your script requires the path to sendmail or $mailprog for easymail this should be entered as:
/bin/easymail
Easymail requires that a valid email address is submitted to make up the From: email header, if your script runs OK but no message is sent it will normally be because the email address used as the From: email address is not valid.