I guess the HTML isn't being sent out because it's still sitting in a buffer somewhere and the main CGI process can't exit and flush the buffer as long as there is still a child process active. Proc::Daemon could do what you want but I don't think that's a particularly good architecture to start with. If myscript.pl takes a long time to run (which is the only reason I can imagine for not doing its job on the main task), you could easily be DOSed by calling the page with step=0 repeatedly. Have you thought about using AJAX? You could load the main page and have it call myscript in the background as a CGI of its own, which would then print its results in JSON or something as they are produced, to be consumed by the JavaScript on your page.

In reply to Re: CGI script calling a perl script by mbethke
in thread CGI script calling a perl script 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.