This FAQ is for people who experienced Internal Server Error on running their Perl script. Hopefully it won't be as tormenting an experience to you as it was to me.
One of the most common errors in executing a Perl script is due to the CR/LF problem (i.e. existence of MS-DOS carriage returns in the script).
What happens when there is a MS-DOS carriage return in your Perl script?
INTERNAL SERVER ERROR
The server encountered an internal error or misconfiguration and was unable to complete your request.
What does the error log says?
(location in redhat linux: /etc/httpd/logs/error_log )
Premature end of script header
How do I check if I have MS-DOS carriage returns in my perl script?
Go to telnet command line and use vi editor to check.
vi -b filename.pl
^M means MS-DOS carriage return
(tip: type :q! to exit vi editor)
How do I fix it?
You can add -w to #!/usr/bin/perl (i.e. #!/usr/bin/perl -w). This seems to be a temporary solution only.
The permanent solution is to delete all MS-DOS carriage returns in the script.
Donboy's suggestion: "Easiest way (for me, anyway) is to use a text editing program that allows you to change it quickly. I'm using Edit Plus from www.editplus.com.
This is a text editor that is like an "advanced" notepad. You can go into the "document" pulldown and look for CR/LF and change it to Unix. it will quickly change those returns into their unix equivalent."
Another way is to write and CHMOD 777 a simple perl script to delete the carriage return (make sure you write this script without MS-DOS carriage return!).
# Usage Notes
# This script erases MS-DOS carriage return that causes errors in perl scripts
# Go to telnet command line
# perl nocr.pl original.txt > modified.txt
# chmod 777 modified.txt
tr/\015//d; # delete octal 15 (carriage return)