Re: CGI ponderings
Tim Bunce (Tim.Bunce@ig.co.uk)
Fri, 16 Jun 1995 20:50:16 +0100
> From: Tom Christiansen <tchrist@mox.perl.com>
>
> I was wondering whether a couple other CGI modules should be
> supplied. One would capture errors and warnings. Here's
> what I've been putting at the top of my scripts:
>
> use CGI::Base;
> use CGI::Request;
> BEGIN {
> CGI::Base::LogFile("/usr/local/etc/httpd/logs/mxperl.log");
> $ADMIN = 'tchrist@mox.perl.com';
> $SIG{__DIE__} = sub {
> $SIG{__WARN__} = sub {
> SendHeaders();
> }
>
Umm, is it worth wrapping into a module? As soon as I think about
generalising it there is almost nothing left. This probably belongs
in the CGI::Base pod text. Should I add it in?
> The other would save punctation, allowing you to write things
> like this:
>
> if (@user_query) {
> H2 "User Query";
> DLstart;
> DT;
> print "You want me to execute the following query:";
> DD;
> P;
> start("CODE");
> print join " and ", @user_query;
> end("CODE");
> DLend;
> } else {
> print "What don't you want a user query?";
> }
>
> Here's a trivial partial implementation :
>
> sub bracket { print "<$_[0]>\n" }
>
> sub HR { bracket "HR"; }
> sub P { bracket "P"; }
> sub BR { bracket "BR"; }
> sub LI { bracket "LI"; }
> sub DD { bracket "DD"; }
> sub DT { bracket "DT"; }
>
> sub start { bracket ($_[0]) }
> sub end { bracket ("/$_[0]") }
>
> sub bracket_pair {
> my($name, $value) = @_;
> start($name);
> print $value, "\n";
> end($name);
> }
>
> sub H1 { bracket_pair("H1", "@_") }
> sub H2 { HR(); bracket_pair("H2", "@_") }
>
> sub ULstart { start("UL") }
> sub ULend { end("UL") }
> sub DLstart { start("DL") }
> sub DLend { end("DL") }
> sub OLstart { start("OL") }
> sub OLend { end("OL") }
>
> Have these two things been done before and did I just miss it?
The first, no. The second has been done on the grand scale in the HTML::Base
module but I think there's room at the bottom-end of the market :-)
> Should they be? What should the modules be named?
>
Probably not for the first one. For the second, how about:
HTML::Simple;
or HTML::Trivial;
or HTML::Tiny;
or ...
I probably wouldn't implement bracket though. The cost/benefit is too close.
> --tom
>
Tim.