Apache-ASP
view release on metacpan or search on metacpan
site/articles/perlmonth1_intro.html view on Meta::CPAN
application development, which promised to be maintainable, powerful,
and fast. But support for perl under PerlScript was shoddy, VBScript,
ASP's native tongue, seemed a pathetic alternative, and an NT/IIS solution lacks a certain
portability. Thus I was led to developing <a href=http://www.apache-asp.org>Apache::ASP</a>,
which runs under Doug MacEachern's <a href=http://perl.apache.org>mod_perl</a>
for <a href=http://www.apache.org>Apache</a>.
<h3>Maintainable</h3>
I had been doing CGI style web applications for a couple of years already,
and had never been quite satisfied with the CGI programming,
growing less so as the HTML I was working with became increasingly more
complex than the CGI it was embedded in. The idea of embedding the scripting
within the flow of the HTML seemed like a more natural fit over time.
This natural flow speaks to the heart of <b>maintainability</b>,
where another developer can pick up your code and get a feel for
it on the first read.
<p>
Check out the difference in how it feels to embed the HTML
in the scripting, versus embedding the scripting in the HTML.
A reasonably complex table, which is structurally HTML heavy,
only touches the tip of the iceberg:
<p>
<table border=2 bgcolor=blue>
<tr><td>
<table border=4 bgcolor=white>
<tr><td>SOME</td></tr>
<tr><td>DATA</td></tr>
</table><td><table border=4 bgcolor=white>
<tr><td>TO</td></tr>
<tr><td>LOOP</td></tr>
</table><td><table border=4 bgcolor=white>
<tr><td>OVER</td></tr>
<tr><td>:)</td></tr>
</table>
</td></tr>
</table>
<p>
Coding this table in CGI, you might get:
<pre>
<hr width=90% size=1>
use CGI qw/:standard *table/;
my(@data) = ('Some', 'Data', 'To', 'Loop', 'Over', ':)');
print
header,
start_html('Example'),
start_table({-border=>2, -bgcolor=>'blue'}),
Tr,td,
start_table({-border=>4, -bgcolor=>'white'})
;
# pretend we are reading from database cursor, so code
# would be written like so
my($data, $count);
while(@data) {
if($data and $count++ % 2) {
print end_table,td,start_table({-border=>4, -bgcolor=>'white'});
}
$data = shift @data;
print Tr({align=>CENTER},
[td([uc($data)."\n"])]
)
;
}
print
end_table,
end_table,
end_html
;
<hr width=90% size=1>
</pre>
When designing the above table ASP style, a much more
natural flow to the script takes form, wherein the developer
can literally see the table in table layout of the page:
<pre>
<hr width=90% size=1>
<% my(@data) = ('Some', 'Data', 'To', 'Loop', 'Over', ':)'); %>
<html>
<head><title>Example</title></head>
<body>
<table border=2 bgcolor=blue>
<tr><td>
<table border=4 bgcolor=white>
<%
my($data, $count);
while(@data) {
if($data and $count++ % 2) {
%>
</table><td><table border=4 bgcolor=white>
<%
}
$data = shift @data;
%>
<tr><td><%=uc $data%></td></tr>
<%
}
%>
</table>
</td></tr>
</table>
</body>
</html>
<hr width=90% size=1>
</pre>
<p>
Doesn't the HTML-centric ASP read better? You'll see that
this becomes more true as the html of your site becomes increasingly
complex.
<p>
( run in 0.648 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )