Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: CGI.pm HTML shortcuts

by OeufMayo (Curate)
on Apr 19, 2001 at 23:00 UTC ( [id://73932]=note: print w/replies, xml ) Need Help??


in reply to CGI.pm HTML shortcuts

I like to keep control of the HTML that I write..

<AOL>Me too!</AOL>, but that being said, I never had been disappointed by the HTML output of CGI.pm. It's not as if you're using softwares like Dreamweaver, Frontpage or GoLive, which rely mostly on the inability of the user to actually write HTML, and thus output their own more or less mangled version of HTML.

CGI.pm on the other hand doesn't produce automatically HTML, you can mess up any way you want with the elements attributes (which is wrong), or put elements in the wrong places (TABLE tags in the HEAD, tags after the HTML ending, etc...). The big advantage of CGI.pm is to automatically generate valid XHTML, which is a Good Thing™.

For the speed question, everything comes at a price, and your process will use more resources to call the HTML tags from CGI than to simply print an interpolated string, but you usually doesn't have to worry about it as it is not a huge bottleneck (provided that you imported the html tags beforehand). If you already use CGI.pm in your script the overhead of generating the HTML is negligible, in my opinion.

If speed really matters, you should probably use mod_perl instead, with a Template-Toolkit handler. I have not tested this kind of configuration, but it should give quite good results

HTML Here-docs might be fine for small task, but if you have to generate tons of different pages with bazillions of different parameters for each, I'm not sure the guy who will eventually look up at your code later will appreciate that 4/5 of the program is embeded HTML with fragments of perl scattered all around...

<kbd>--
my $OeufMayo = new PerlMonger::Paris({http => 'paris.mongueurs.net'});</kbd>

Replies are listed 'Best First'.
Re: Re: CGI.pm HTML shortcuts
by brpsss (Sexton) on Apr 19, 2001 at 23:24 UTC

    It might be an FAQ, in which case, I am sorry... but how do I import html tags beforehand ?
    Thank you for taking the time out to explain.. you're right.. I have messed up my HTML a lot, when I do it myself.. and of course, an automatic generator won't do that. I don't really know too much about XHTML yet (its something to do with XML, right ?)
    Thanks

      Everything about importing methods in CGI.pm is explained in The Fine Manual that you should Read. A copy is available here.

      All the infos you want about XHTML and more (really more) can be found at the W3C site. Here's the abstract of the XHTML 1.0 recommandations:

      This specification defines XHTML 1.0, a reformulation of HTML 4 as an XML 1.0 application, and three DTDs corresponding to the ones defined by HTML 4. The semantics of the elements and their attributes are defined in the W3C Recommendation for HTML 4. These semantics provide the foundation for future extensibility of XHTML. Compatibility with existing HTML user agents is possible by following a small set of guidelines.

      <kbd>--
      my $OeufMayo = new PerlMonger::Paris({http => 'paris.mongueurs.net'});</kbd>
Re: Re: CGI.pm HTML shortcuts
by mpolo (Chaplain) on Apr 20, 2001 at 20:33 UTC

    If the output is really 4/5 HTML with a smattering of perl, the eperl program works nicely. This automatically generates the Content-type headers. Anything that's inside a "special" HTML tag <? !> is taken to be perl, while everything outside is taken to be HTML. The shebang line changes to something like #!/usr/local/bin/eperl -mc. Eperl calls the perl compiler/interpreter on the machine to handle the perl parts. Supposedly you can get it to work with mod_perl as well, though I haven't tried that myself.

      Please enter "eperl" in the search bar at the top of this page for some dissenting opinions on eperl.

              - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://73932]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-20 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found