Solved

Premature end of script headers

Posted on 2006-07-20
3
474 Views
Last Modified: 2013-12-25
Hi,
   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 127.0.0.1] Premature end of script headers: call.pl
[Thu Jul 20 20:58:20 2006] [error] [client 127.0.0.1] nlib.pl did not return a true value at C:/indigoperl/apache/cgi-bin/call.pl line 2.

Here is the code - very simple - it seemed.

######call.pl

#!perl
require "nlib.pl";
&thank_you;

######nlib.pl
#!perl
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 call.pl 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 nlib.pl call in call.pl

I am stuck behind my simple mind.

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





0
Comment
Question by:nigelbalcarres
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 17149608
nlib.pl needs to return true.  Traditionally, this is done by adding a

1;

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;
<HTML>
<HEAD>
<TITLE>Thank You!</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFCC TEXT=#000000>
<H1>Thank You!</H1>\n";

<P>
<H3>Your feedback is greatly appreciated.<BR>
<P>
</BODY>
</HTML>
EOF
}

1;

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

Author Comment

by:nigelbalcarres
ID: 17149679
Thanks

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

0
 

Author Comment

by:nigelbalcarres
ID: 17149743
Yep - perfect!

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

Thanks a million!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now