?
Solved

Premature end of script headers

Posted on 2006-07-20
3
Medium Priority
?
482 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 2000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
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 strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Suggested Courses

762 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