[rt-users] Re: Perl Question

Bob Goldstein bobg at uic.edu
Thu Jun 10 23:10:48 EDT 2004


>
>I thought of a better way to word my question, and hopefully this will help
>someone understand the conceptual hurdle that I have in learning about
>this:
>What advantage is there to embedding perl in html (I.e. Mason) vs just
>generating the web page using raw perl (probably using cgi.pm to generate
>the html).
>I think my hurdle has to do with the difference between cgi and modperl,
...

Of course, it depends :-)

The simple bottom line for RT is, use Mason.  RT already does,
and you're better off fitting in.

As far as cgi and modperl, 'cgi' is for creating web pages
as the output of real-time programs, whether in perl or C or shell
or whatever.  'mod_perl' is for changing apache's behavior using
perl, which can include auth/auth, url rewriting, logging,
or anything apache does internally.  It so happens that mod_perl
can also run cgi that are written in perl, hence your interest.
But modperl and cgi are not at all the same, they just
happen to overlap in the perl-cgi area.

As far as the straight perl (cgi.pm generation of html to you)
or inside-out (perl inside html, as in Mason or Template::Toolkit),
it's a matter of style and preference.  For really simple
pages, I write straight perl (with print statements, not even CGI.pm)

However, I quickly reach for a templating language when the
page becomes even a little more complicated.  This enables me
to use straight perl for database fetches and complicated
assembly of data to display, and use the templating language
for rendering.  Of course, rendering can involve some computation
(if X is present, display Y, otherwise Z), so you need some
control, not just substitutions.

If I'm careful to put the "what to display" in perl and the
"how to display" in the template, I find my code much
easier to understand and maintain.  So I like both :-)

   bobg




More information about the rt-users mailing list