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.


In reply to Re: eval bug? by ferrency
in thread eval bug? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.