Solved

Premature end of script headers

Posted on 2006-07-20
3
481 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 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