One script or many: When the user is posting changes, I have found it helpful to have two scripts. Let's call them show.pl and post.pl. The various forms specify post.pl in the action for the <form...>. Then after processing the post, the post.pl script spits out an HTTP location header line that takes the client browser back to the show.pl script displaying whatever is appropriate.

This is nice for separating functionality. But more importantly, because the page the browser sees is not a direct response to a form, the dreaded "Repost form data?" pop-up message does not appear if the user happens to hit Reload.

Output, wait 30 seconds, output another page: Normally you cannot do that (check on push techniques if you want to explore doing it). Think about it, the server only serves when a browser requests a page. The browser only is ready to receive a page right after it has send the server a request. Even if you had the server spit out another page, the browser would not be waiting for a page and would just ignore it.

If you meant, can a script respond to one browser request and then the same script respond to a different browser request 30 seconds later, the answer is Yes. Which brings us to:

Some mechanism to decide which subroutine... Three ways come quickly to mind.

   1)Query string values
   2)Extended url path values
   3)<input type=hidden...>

If you need more info about any of these, just repost and I or someone else is sure to respond.

And of course you are using CGI.pm...

Good luck.


In reply to Re: CGI: Make one big program or lots of little ones? by dvergin
in thread CGI: Make one big program or lots of little ones? 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.