On Sep 25, 2009, at 6:14 AM, Michael Peters wrote:

On 09/25/2009 08:17 AM, Chuck Crisler wrote:

# output a document
print $query->header();
print $query->start_html(-title=>"Howdy",
                         -style=>{-src=>'./dynamic.css'});
print $query->h1('Form Data');

Also, not to confuse you too much, but most people don't use CGI.pm's HTML generation features any more. Most of us have moved on to using HTML templates which makes it even easier to separate things out. And it's more like editing a normal HTML file which is what most designers are familiar with.

You should check out Template Toolkit (http://search.cpan.org/perldoc?Template ) or HTML::Template (http://search.cpan.org/perldoc?HTML::Template).

or just print the html. When executed as a cgi script, the outgoing connection from Apache is the script's stdout. Variables substitute just fine.

print <<EOF;
Content-type: text/html\n\n
<html>
<link rel="stylesheet" href="./dynamic.css" type="text/css"
<title>Howdy $username!</title>
...
</html>
EOF

Works for us.

This way I can do large swaths of straight html code without any issue, and no potential complications from added modules.

I can also split the raw html into pieces so I can insert dynamically created tables, etc.

I've used this to output pre-encoded rtf with variable substitution, too.

(Hint, use Windows Write to generate the RTF, it makes simple, easy to parse and customize rtf files. The RTF emitted by Word or TextEdit is ginormously complicated)

--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group

Institutions do not have opinions, merely customs


Reply via email to