I find that its much easier to use a single script split up into subs. Its fairly easy to invoke the subs by setting a variable to do so in the form you are submitting:
... <input type="hidden" name="op" value="some_operation"> ...
and in your script, you'll want to do something like this
... #(generic code / beginning of HTML dumped here) &$op(); ... #(generic code / end of HTML dumped here)
of course, its possible that someone playing with your form could execute subs that you'd rather they not, so I suggest creating an array, with the names of subs that are "safe" to run: example:
@safesubs = ("this_sub", "that_sub", "other_sub"); $ok = 0; #op is not okay to run until we say so ;-) foreach (@safesubs) { if($op eq $_) { $ok = 1; #if the op is safe, set $ok to true } } if($ok) { &$op(); } else { die("The op variable does not contain a valid definition"); }
Or something along those lines. I hold the mindset that a CGI is responsible for accomplishing a certain task, such as dealing with user administration, for instance. That one script should allow me to add, edit, and/or delete users at whim, without calling on other scripts to do the job. Besides, it keeps your cgi-bin a lot cleaner ;-)

I've never claimed to be a Perl God(TM), and any claims to the converse are used fictitiously.

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