perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garth Webb <ga...@zappos.com>
Subject Re: Handlers vs Perl scripts
Date Tue, 27 Jan 2004 22:03:31 GMT
On Tue, 2004-01-27 at 12:45, Hemond, Steve wrote:
> Could anyone explain me why having perl files like :
> 
> printf ("<HTML> blahblahb");
> printf ("My name is %s",$name);
> 
> Is a wrong idea? :-)

For one, most HTML pages will probably contain more than one tag and
more than two lines of text.  Take this bit of code from cvsweb.cgi (a
very handy CVS viewer) which contains all the code and all the HTML in
one file:

======

$infocols++;
printf '<th style="text-align: left; background-color: %s">',
  $byrev ? $columnHeaderColorSorted :
  $columnHeaderColorDefault;

if ($byrev) {
    print 'Rev.';
} else {
    print &link(
		'Rev.',
		sprintf(
			'./%s#dirlist',
			&toggleQuery("sortby", "rev")
		       )
	       );
}
print "</th>\n";
$infocols++;
printf '<th style="text-align: left; background-color: %s">',
  $bydate ? $columnHeaderColorSorted :
  $columnHeaderColorDefault;

if ($bydate) {
    print 'Age';
} else {
    print &link(
		'Age',
		sprintf(
			'./%s#dirlist',
			&toggleQuery("sortby", "date")
		       )
	       );
}
print "</th>\n";


====

Now, can you tell me how many columns of a table this will construct at
a glance?  Note that this only outputs a single row.  Can you imaging
how much more code exists to output the rest of the table?

What happens if the code works perfectly, but you want to change the
layout?  The Perl must be reworked as much (and sometimes more) as the
HTML.  Not only is it difficult and tedious to find the right HTML when
its completely interspersed with Perl, but you run the risk of breaking
your already working Perl code, or worst introducing a hidden bug.

Additionally if you have a programmer and a designer, mixing HTML and
Perl means that your designer has to be a decent coder and the coder has
to be a decent designer.

That's why its a bad idea! :)

-- 

 |- Garth Webb       -|
 |- garth@zappos.com -|

Mime
View raw message