Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have tried almost everything you've said, and no matter what I get "premature end of script headers" or "Could not run due to compilation error." Server logs tell me that print "</html>"; is a syntax error, as is print qq~ <a href="/index.html">Click here!</a> ~; HELP!

Replies are listed 'Best First'.
Re: More Script Header Problems
by ides (Deacon) on Jun 20, 2002 at 21:21 UTC
    Running perl -c on your CGI script will show you what lines Perl says there are syntax errors. If you start at the top of the list and work your way down you'll be able to find your problems pretty quickly I would imagine.

    You use it like: perl -c your.cgi

    -----------------------------------
    Frank Wiles <frank@wiles.org>
    http://frank.wiles.org

Re: More Script Header Problems
by TGI (Parson) on Jun 20, 2002 at 20:51 UTC

    Try running your perl code from the command line. Enable warnings and diagnostics. You probably left a semicolon off the end of a line, or have a multiline quote that isn't terminated where it should be.

    If you aren't using the CGI module, do so. Besides having excellent parameter handling, it makes it easy to test CGI scripts at the command line.


    TGI says moo

      Without being nitpicking I suggest also:

      use diagnostics;
      As this is more elusive upon single error messages and sometimes contains good hints on how to fix the bug :-)


      Have a nice day
      All decision is left to your taste
Re: More Script Header Problems
by ckohl1 (Hermit) on Jun 20, 2002 at 20:55 UTC
    Could you post the offending code?

    Chris
Re: More Script Header Problems
by little (Curate) on Jun 21, 2002 at 16:44 UTC
    perl is trying to interpolate the string you gave to print. Using single quotes or noninterpolative quotation will help you to avoid that problem. eg.;
    # simple print '</html>'; # or escaped sop perl knows what you want print "<\/html>";
    So the syntax error is just that there is no such thingy as /h
    Have a nice day
    All decision is left to your taste