Maclir writes: There seem to a a number of ways of building CGI programs with perl; CGI.pm , the other CGI:: modules, HTML::Embperl, HTML::Mason. I have played around with CGI.pm and embedded parl (HTML::Embperl), and there are good and bad points with both.
What is the collected experiences and recommendations of the "use Perl;" community? (I can do without the "Python rulez" or "PHP is much better" comments - that is why I asked here and not on
ADVA-thanks-NCE
My only beef with CGI.pm is that it mixes two technically distinct feature sets into one module: The HTTP/CGI protocol complex (parameters in, URL handling, content out) and HTML (fonts, tables, etc.).
But that said, even if you only need the parameter parsing, it's madness to try to roll your own code instead of using CGI.pm. There are just too many weird rules and exceptions in the CGI and HTTP specs. And that's kind of what code reuse is supposed to help us with, right?!
It all comes down to "how do you want to mix your code and your HTML?" CGI.pm has shortcuts to generate HTML, but this means that you must change your program to change the HTML it produces. Most folks don't want to give their idiot cow orkers the ability to edit their code, nor do we trust idiot cow orkers to able to write Perl to make HTML when they have enough problems "programming HTML" as it is.
HTML::EmbPerl is a reversal: instead of putting HTML into your programs, you put Perl into your HTML. The files are processed by the web server and their output is sent back to the browser.
Mason and the Template toolkit are the next level up from EmbPerl. While HTML::EmbPerl generates one page, it doesn't have very good facilities for combining pages. Mason and Template.pm are excellent for building component-based websites. These are website where you have pages with common elements: nav bar, ad line, search box, personalised links, etc. Each of these things becomes a component and you can easily build pages made from these components.
When I write a single CGI program, I use CGI.pm. I either use CGI.pm's HTML shortcuts or I use a simple template system like Text::Template or my own s///. When I have to build an integrated system of web pages, then I use Template or Mason.
Nat