Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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?

In reply to Should One Use CGI.pm to Generate HTML? by sierrathedog04

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found