in reply to How to get over 'premature end of script headers' in Apache?

That only happens when your script had an error in it and perl was not able to compile it successfully. Always test your script first before deploying it as a CGI. perl -c as a minimum.

You could also look at CGI.pm 's fatals_to_browser define.