we tend to use a Perl/CGI program to draw up the form (context 1) and when the user submits the form data some parameter gets checked to see what context we are in, and we accept the form data via the same program (context 2). The first lines of code in the program center around finding out what context it is supposed to be in. Furthermore the program has to have multiple sections of code, each dealing with actions related to a particular context

Hmmm ... that must be the royal we. I sure don't do that. I tend to break my applications into different *namespaces*. This not only gives cleaner code (and less to mentally chew on) but allows me to play apache tricks (no access control on display and/or results but access control on updates).

As for Ajax, you can have the same big ball of mud as you do with *normal* cgi - its just cleared the picture for you. The picture was cleared for me when the access control became a biz requirement and became crystal clear when I started using CGI::Application.

-derby

In reply to Re: Encapsulating web client side code in Perl modules? by derby
in thread Encapsulating web client side code in Perl modules? by varian

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.