Class::CGI 0.10

Ovid on 2006-04-17T02:30:29

I've just uploaded Class::CGI 0.10 to the CPAN and it should hit mirrors soon. I've finished implementing better error handling and while enhancements to the module are anticipated, it's essentially feature complete. Now you can do stuff like this:

use Class::CGI
    handlers => {
        customer => 'Class::CGI::Customer',
        date     => 'Class::CGI::Date',
        order    => 'Class::CGI::Order',
    };

my $cgi      = Class::CGI->new;
my $customer = $cgi->param('customer');
my $date     = $cgi->param('date');
my $order    = $cgi->param('order');

if ( my @errors = $cgi->errors ) {
    # do error handling
}

Basically, each ¶m call, if dispatched to a handler, is wrapped in an eval and if an exception is thrown, the method call returns false and an error is pushed onto an internal stack. The &errors method returns those errors (and there's a corresponding method to clear that stack, if needed). By using this strategy, you can attempt to fetch all of your form data at once and report all errors at the same time.