[boulder.pm] CGI.pm basics
Walter Pienciak
walter at frii.com
Thu Jan 20 16:59:24 CST 2000
On Thu, 20 Jan 2000, Wayde Allen wrote:
> On Thu, 20 Jan 2000, Walter Pienciak wrote:
>
> > my $q = CGI->new();
> > print $q->header();
>
> So, is there a particularly compelling reason to use the object oriented
> approach over the function call? Something like:
>
> new CGI;
> print h1("My Header Text");
>
> - Wayde
> (wallen at boulder.nist.gov)
I can't think of *any* compelling reason to use the object-oriented
approach (this is a cue for the C++ trained academics to rise up
en mass and beat us to pulps).
I think that I use this approach because (1) it's what I learned first, and
(2) I tend to use cut-and-paste methods to reuse boilerplate stuff.
Your code is a good example of a different style between two people
using the same module. Me, I have a *strong* preference to see the actual
HTML -- just as strong a preference as people who *hate* looking at it. The
output is the same; the code is different.
I had a conversation with a co-worker just today about coding style.
He's very comfortable in C, and even after working for two years in Perl
he insists on writing Perl code that looks like
if ($baz eq "boz")
{
print "foo";
}
else
{
print "bar";
}
and finds it easier to understand than a more Perlish idiom.
Walter
More information about the Boulder-pm
mailing list