Matt,

CGI.pm has some decent functionality for print HTML from Perl, if you are
not worried about making your pages look pretty. It does offer some limited
support for style sheets, but usually if I want my HTML to look nice, I just
use a HERE doc. You should be able to save the following example as a .cgi
or .pl file on your server and run it as long as you have the file
permissions set to executable.

######## snip #########

#!/usr/bin/perl

use CGI;       # use CGI.pm
$q = new CGI;  # initiate a new CGI object
$q->header();  # write an HTTP header to the browser

# This is the HERE document:

print <<END_OF_HTML;
 <html>
 <head>
 <title>Matt's Test HTML Page</title>
 </head>
 <body bgcolor="#cccccc">
 <h3>Matt's Test HTML Page</h3>
 <font face="Verdana" size="2">
 This is a page with a gray background using the <b>Verdana</b> font.
 </font>
 </body>
 </html>
END_OF_HTML

# Make sure you have at least one carriage return
# at the end of the HERE document.

######## snip #########



A more basic HTML document could have been done using CGI.pm, but without
the style control:

######## snip #########

use CGI;       # use CGI.pm
$q = new CGI;  # initiate a new CGI object
$q->header();  # write an HTTP header to the browser

$q->start_html; # start the HTML doc
$q->title('Matt\'s Test HTML Page'); # write a title
$q->h3('Matt\'s Test HTML Page');    # write an <h3>
$q->p('This is an HTML page without the fancy stuff.'); # <p>
$q->end_html; # end the HTML doc

######## snip #########


You can add style to HTML documents generated with a CGI object. For that,
read the perldoc on CGI.pm about style sheets.

Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]
www.insiteful.tv





-----Original Message-----
From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 11:22 AM
To: [EMAIL PROTECTED]
Subject: html in a cgi script


I am just starting to learn perl and am reading about cgi.pm
I have read about creating an appropriate header and using the start_html
line, but can someone please give me an example of their html inside a
script?

TIA

--
Matthew Harrison
Internet/Network Services Administrator
Peanut-Butter Cheesecake Hosting Services
genestate
www.peanutbuttercheesecake.co.uk


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.333 / Virus Database: 187 - Release Date: 3/8/2002

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.333 / Virus Database: 187 - Release Date: 3/8/2002


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to