Hi Monks,

I have a CGI script that accepts input from a form and processes data accordingly. The processing usually involves parsing through hundreds of megabytes of flat text for certain values and doing some trivial formatting and arithmatic on them. Due to the sheer volume of data that has to be processed, this can take several minutes.

What I would like to do is this: once the user clicks the "Submit" button on the form, he would see a page that says something to the effect of "Processing.....". When the script finally finishes gathering all of it's data, the page would display the results. I'm looking for suggestions on how to accomplish this using perl.

My original though was to simply use fork. One process would create a static HTML file with a page that refreshes every X seconds. The other process goes out and parses the data. When it finishes, it overwrites the static HTML page with the results. Thus, when the user's browser refreshes the page, instead of seeing "Processing..." he would see the results. This technically works, but it also means I have to figure out how to clean up the HTML files once they've been viewed and are no longer needed (which is a bit less than trivial in a multiuser environment in which each user may have several open sessions). A better solution would be to never have to write an HTML file to begin with.

Is there a good way to do this? Thanks for your suggestions.

In reply to CGI: Waiting for Output 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.