Premature end of script headers

   I am (trying) building dynamic forms in perl.

I use indigoperl - incs Apache, php, perl and mysql.

My task at the moment is to get one perl script talking to another. The idea is that one perl library file contains subroutine so that they can be called externally from a calling form.

The calling form should have html in it along with logic.

The calling form having required the perl file that holds the subroutines calls the appropriate subroutine. The routine then performs some magic - return html content to the calling form.

I get an error 500
checked the error log and found...

[Thu Jul 20 20:58:20 2006] [error] [client] Premature end of script headers:
[Thu Jul 20 20:58:20 2006] [error] [client] did not return a true value at C:/indigoperl/apache/cgi-bin/ line 2.

Here is the code - very simple - it seemed.

require "";
sub thank_you{
      print "Content-type: text/html\n\n";
      print "<HTML>\n";
    print "<HEAD>\n";
    print "<TITLE>Thank You!</TITLE>\n";
    print "</HEAD>\n";
    print "<BODY BGCOLOR=#FFFFCC TEXT=#000000>\n";
    print "<H1>Thank You!</H1>\n";
    print "\n";
    print "<P>\n";
    print "<H3>Your feedback is greatly appreciated.<BR>\n";
    print "<P>\n";
    print "</BODY>\n";
    print "</HTML>\n";

Howver. The idea would be that is the template holder of html/body until closing tags. In the middle of these tags would be calls to nlib to build the web page.

what appears to be something simple - is baffling me to the nth degree.

Checked the htdocs and found:
### Section 2: 'Main' server configuration
#ISEXT next 2 lines are need to allow execution of script in the root directory
AddHandler cgi-script .pl
AddHandler cgi-script .cgi

I even removed .pl from call in

I am stuck behind my simple mind.

I could use a hand if you have the time, please.

Who is Participating?
TintinConnect With a Mentor Commented: needs to return true.  Traditionally, this is done by adding a


to the end of the file

BTW, you should learn about heredocs, eg:

sub thank_you{
    print "Content-type: text/html\n\n";
    print <<EOF;
<TITLE>Thank You!</TITLE>
<H1>Thank You!</H1>\n";

<H3>Your feedback is greatly appreciated.<BR>


You should also improve your HTML skills by running the generated HTML through a HTML validator.  You'll find there are loads of errors.
nigelbalcarresAuthor Commented:

 will give it a go. Very new to perl - Well, used it years and years ago - its like japanese at the moment.

nigelbalcarresAuthor Commented:
Yep - perfect!

I do use heredocs - the latter not a good example.

Thanks a million!!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.