If a PERL script does not execute correctly check the following:
1) Upload the file in ASCII mode.
2) Make sure the PERL script is uploaded to the cgi-bin directory.
3) Set the PERL script's permissions to 755
4) On a VPS, make sure your site's cgi-bin directory is set to 755 permissions. Any other set of permissions (including 777 permissions) is likely to result in the "Premature end of script headers" error message.
5) If you have access to a Linux shell prompt for the site, try executing the command:
perl –c filename.pl
This will check the PERL script for correct syntax, as well as help determine if the file was uploaded in binary mode.
6) If you have access to a Linux shell prompt for the site, execute the script. If your working directory is the directory the script is in, execute the following command to execute the script:
7) Check the Apache error log for the site. Frequently there are clues to why the script is not executing correctly in the Apache error log.
8) Check the size of your log files. If the /var/log/httpd/suexec.log is 2 GB in size your perl scripts will return a "Premature end of script headers" error message.
In the above examples, replace "filename.pl" with the actual name of your PERL script.