Lately, most of the code I write for CGI's generally
follows the same basic design pattern:
- Receive the values with CGI.pm.
- Validate and detaint the parameters with HTML::FormValidator.
- <shamless plug>Build a multi-dimensional hash with
CGI::State</shameless plug>
- If there is an error, or missing field, use HTML::FillInForm
and HTML::Template to re-fill in the form with the
submitted data and print an error.
- Do some work, usually with DBI, etc
- Use HTML::Template to display a page to the
user either prompting the user for more info, or display
the results of the work.
(I hear that Apache::Pagekit encapsulates alot
of this into a single framework, but I am not convinced that
the platform is stable enough for my needs yet.)
The great thing about HTML::FormValidator is that
you can set up "validation profiles". By this I mean you
can built a set of rules for a newsletter subscription, or
an order submission, for example. The design of the module
allows it to share these pre-made profiles with many other
scripts. Once you write a profile for what I call a
"web object", you can reuse it over and over for the same
type of data.
If your 40-odd scripts are asking for similar types of
data, using this module might be a good way to factor out
all the validation and detainting code.
Update: Sorry, I see that you have 40 elements
per form, not scripts. Either way, this module *will*
save you enough time, so you can concentrate on Quake more =)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.