Several days ago some wandering perl monks advised me to learn to use cgi.pm. It seems like a great help in accessing cgi form variables: instead of parsing my environmental variables to get rid of those "%" symbols inserted by CGI, I simply call param() to get my form variables back the way they were entered.
I wonder, however, if it is worthwhile to use CGI.pm to write HTML. For instance, I was surprised to note that the startform method does not include a built-in parameter to give the form a name. (A workaround is to make the first argument to startform be an associate array whose key value is "name").
Because of gotchas like the above the CGI.pm module, when used to write HTML as opposed to parsing form values, might arguably be harder to read than simply printing the desired HTML as a string direct to the browser.
In fact, I came across an old tutorial at the University of South Wales in Australia which stated "CGI.mp is a perl module providing functions/methods that make it easy
- to access data items and other infor available to the CGI script
- to produce HTML output from the script (IMO this is debatable)
Before I start using CGI.pm to write all of my new dynamically generated web pages, I was wondering what is the most common practice of the monks. Do they print their HTML directly to the browser as strings, or do they use CGI.pm's functions for this purpose?
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.