in reply to RFC: CGI/MySQL - improving my code

Using your code as a specification, rewrite it using CGI::Application, DBIx::Class (or Class::DBI), and Template Toolkit. While there's a learning curve on each of those distributions, you will thank yourself in the morning.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Replies are listed 'Best First'.
Re^2: RFC: CGI/MySQL - improving my code
by lima1 (Curate) on Mar 27, 2006 at 14:29 UTC
    two hints if you decide to rewrite your app and if you want a good cgi:
    • use taint mode
    • add a apache mod_perl AND a cgi configuration, e.g. 127.0.0.1/perl/script.pl runs your script in mod_perl, 127.0.0.1/cgi-bin/script.pl in classical cgi environment.
    developing in cgi has some advantages (you see performance problems better, you don't have to restart apache) but you also should test mod_perl regulary.
Re^2: RFC: CGI/MySQL - improving my code
by Melly (Chaplain) on Mar 27, 2006 at 11:46 UTC

    Hmm, well CGI::Application is already on my list.

    I intend to use HTML::Template rather than Template Toolkit - any thoughts?

    I'll look into those DBI modules - I did wonder whether I should just carry on implementing DBI or whether there were useful modules that present a cleaner code-base for sql transactions (my reservations about such a module would be that it either makes too many assumptions about what you want to do, or ends up not really being much different from rolling your own sql).

    BTW fixed typo - HTML::Template rather than HTML::Application iirc

    Tom Melly, tom@tomandlu.co.uk
      I agree with dragonchild: Template Toolkit is very much worth the learning curve.

      I've been using HTML::Template for a long time now, but TT's dot notation alone is such an amazing feature that it's inspired Mark Stosberg and me to write HTML::Template::Pluggable to provide HTML::Template with the same feature. You can take it from me that TT's implementation is far superior.

      Even if you write the database objects yourself from scratch, it's still worth doing, to isolate that code from the rest of your program. You may actually want to try writing it from scratch once, just to see what's involved.

      In most cases you can mix your own hand-written SQL with these modules. You'll find that Rose::DB::Object provides the ability to do almost any SQL you need without resorting to that though.

Re^2: RFC: CGI/MySQL - improving my code
by CountZero (Bishop) on Mar 27, 2006 at 21:52 UTC
    Or Catalyst.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law