That error message--"premature end of script headers"--doesn't
necessarily mean that your script died. It could also mean that
your script printed something out before it printed out the
HTTP headers. Could that be the case? Try running it from
the command line, using the "real server", and see what
gets printed out, and in what order.
If you're getting content before headers, that's probably
your problem. | [reply] |
Have you tried something like this:
eval { die "Uh oh, bad stuff happened." };
die $@ if $@;
print "Phew. Bad stuff didn't happen.\n";
Perhaps if you posted the relevant section of your code we can take a closer look. | [reply] [d/l] |
Although you didn't state it explicitly, it sounds like you're building a cgi-bin script.
The "Premature end of script headers" error sounds like your web server complaining, not like perl.
The basic problem is, in CGI land, your script must print out valid HTML headers before it prints out Anything Else.
Depending on your web server, there are several techniques you can use to try to debug this.
Looking in your web server's error log can sometimes give you more information on how your script failed.
Running the script from the command line (possibly with a $DEBUG flag, which when active, sets values that would otherwise come from a POST or GET)
can help, but unless you have hot pipes on ($|=1), the script output might come out in a different order than it does in CGI-land.
Another sometimes useful technique is to put a BEGIN block that prints out a valid header, for debugging:
BEGIN { print "Content-type: text/plain\n\n"; }
That will be run before the rest of your code, and will usually ensure the header gets printed out before anything else.
Then you can see what the Next Thing is that's printed out; if it's not a valid header, then you know you have a problem.
And of course, if you give more details on your setup and code snippets, I could make more suggestions.
| [reply] [d/l] [select] |