Morning All,

I'm responsible for a small community website, being in the middle of a redesign to allow us to provide some member-specific content, and moving from an SHTML/PHP-based solution to a Perl/CGI one.

I've implemented a fairly simple application to handle the majority of user requests and information processing. My main niggle with this at the minute (and the point of this post) is the script's event handling (requests for pages, user login/logouts, this sort of thing). This currently takes the form of a set of if ... then ... else statements, but seems to run quite slowly when there's load on the site, and I'm generally not happy with it - the code is ugly, and already a nightmare to make changes to.

I'm considering implementing a system whereby CGI parameters directly map to subs, probably through a hash (as eval &$c->param is obviously insecure), but I'm not 100% convinced that this is the most sensible way to go.

I've also looked at the CGI::Application module, but I can't help but think that this would be overkill for what I'd be doing with it.

I'd be interested to know what suggestions people have for event handling with CGI, and opinions of the "best" way to go with this.

Thanks in advance,
-- Foxcub
A friend is someone who can see straight through you, yet still enjoy the view. (Anon)


In reply to Event Handling in CGI by Tanalis

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.