spickles has asked for the wisdom of the Perl Monks concerning the following question:

My cgi file errors out with 'Premature end to script headers'. I'm using CGI::Carp to output the errors to the browser. I've come across this error before, and I believe I have the most common problem solved with 'print $q->header;' This script, which grabs info from a table and prints a report, worked fine on this database installation on another server. I'm reviving it and continuing on a different machine. I checked the apache log, and it indicates a compilation error on line 7:

Tue Feb 10 22:28:12 2009 error client 127.0.0.1 BEGIN failed--compilation aborted at H:/xampp/cgi-bin/generate_report.cgi line 7.\r, referer: http://localhost/select_report.php?school_name=ACES
The first few lines look like this:

#!c:/Perl/bin/perl -w # PERL MODULES WE WILL BE USING use Net::Telnet; use Net::Telnet::Cisco; use DBI; use DBD::mysql; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use dbConnect;


Line 7 is 'DBD::mysql;' and that is currently installed in the library and is version 4.007. Any suggestions?

Regards,
Scott

Replies are listed 'Best First'.
Re: Premature End Script Headers
by CountZero (Bishop) on Feb 11, 2009 at 06:39 UTC
    What happens if you leave out the offending line? DBI will call DBD::mysql itself when it connects to the database so use DBD::mysql is not really necessary.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      I think I've got a corrupt installation. I'm going to start over and post back.
Re: Premature End Script Headers
by Anonymous Monk on Feb 11, 2009 at 04:45 UTC
    That is only part of the error message, show the rest.