[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Best Practices: CGI.pm & CSS2 ???



CSS is not deprecated. It is not reliable for positioning but it is quite
usable for defining text and character styles.   If you have ever
changed all the font tags in a web site, you will be a CSS fan.

If you attempt to validate your HTML against w3.org's validator, you
are required to be a fan.

	http://validator.w3.org/

It is probably not a good idea to use CGI.pm to produce HTML output. Why
learn another HTML syntax ? Something like HTML::Template or even a HERE
document will serve you better.

However it is very foolish to **Not** use CGI to parse input from a form.
It is much, much easier and safer than parsing the raw query string or
reading STDIN or escaping shell charactors or otherwise doing the job by
hand.

#!/usr/bin/perl -wT
use strict;
use CGI;
use CGI::Carp;
my $q    = new CGI;
my $name = $q->param('first_name') || 0;

my $result = <<HERE;
Content-Type: text/html; charset=ISO-8859-1\n\n
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html>
<head><title>Hello $name</title></head>
<body><p>hello $name</p> </body>
HERE

if ($name) {
    print $result;
}
else {
    print <DATA>;
}

# see perldoc perldata for __DATA__ file handle info
__DATA__
Content-Type: text/html; charset=ISO-8859-1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html>
<head>
<title>simple form</title>
</head>
<body>
<form action="/cgi-bin/foo.pl" method="get">
<p>Name:<input type="text" name="first_name"></input></p>
<p><input type="submit"></input></p>
</form>
</body>
</html>

#########

On Tue, 30 Dec 2003, Chris Wagner wrote:

> I can tell you some stuff about that right now.  CGI.pm is just a quick and
> dirty module that will save on some typing in your perl script.  Emphasis on
> some.  If you're doing anything more than basic html tags it quickly becomes
> not worth it anymore.  Writing tag attributes takes up more time and space
> than just writing out the html itself.  The one thing it's really good for
> is writing out tables.  If you have an array with all your row data you can
> write something like print Tr( td(\@array) ).  That saves a lot of typing.
> The perldoc has most of the gritty details.
>
> Cascading Style Sheets.  Deprecated.  I have seen so many bad uses of style
> sheets it makes me want to cry out in anger.  So just don't use them unless
> there's no other way to do it.  They are almost guaranteed to cause
> compatibility problems.  The problem is that some bonehead writes a style
> sheet that makes a webpage look good on *their* computer.  To hell with
> everybody else who doesn't have the same monitor, resolution, fonts,
> browser, etc.  The one thing they are "good" for is making themes but be
> careful that it's still ledgible on other machines.  I have them turned off
> in my browser.
>
>
> At 10:50 PM 12/29/03 -0600, Michael D Schleif wrote:
> >Please, somebody point me to URL's that provide examples and best
> >practices of using CSS2, CGI.pm and XHTML v1.x.
> >
> >--
> >Best Regards,
>
>
>
>
>
> --
> REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
> "...ne cede males"
>
> 00000100
>
>
>







Reply to: