fork is your friend. Fork off a copy of your script and have it do whatever it needs to do. A fork + exec may be better, if you want to do something else in its place.

Caveat - if you're running in a mod_perl environment, you're gonna fork your entire apache process, which has memory overhead concerns among other issues that I always seem to forget. Filehandles, is it? Only do it here if you absolutely have to. CGIs? No sweat.

From there, just proceed as before - refresh the user back to some other page, and when your forked process completes, give it someway to flag its being finished. Touch a file, update a row in a database, something. Something that can be a quick and simple check for the front end to do.

To show the user the changes, there are several approaches - have 'em constantly click a button ("Am I done yet?") to refresh the page and display results if appropriate. Or bring up a "loading..." screen that watches for the update and refreshes when it gets it (note that this blocks the user), or do something fancy and ajaxy that autorefreshes (or gives a refresh button) when the data is actually there.


In reply to Re: calling one cgi script from another by jimt
in thread calling one cgi script from another 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.