Ovid (publius_ovidius) wrote,
Ovid
publius_ovidius

Class::CGI

On the off chance that any Perl folk read this journal instead of my technical journal and are interested in Class::CGI, you can join the mailing list to help contribute to its design and to ask questions about its use.

    use Class::CGI 
      handlers => {
        customer => 'My::Customer::Handler',
      };  # can also be specified in a profile file

    my $cgi      = Class::CGI->new;
    $cgi->required(qw/customer age/);  # On my hard drive.  This feature is not yet released.

    my $customer = $cgi->param('customer');
    my $name     = $customer->name;      # objects!
    my $email    = $cgi->param('email'); # behaves like normal

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

Class::CGI is an example of the mediator pattern. This pattern lets you provide a single interface to a collection of interfaces without tightly coupling them. Specifically, Class::CGI lets you treat HTML forms as object collections. The validation and untainting of form data can all happen behind the scenes. This lets your core code focus on the business problem you're trying to solve rather than worry about a bunch of grunt work.

Tags: perl, programming
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments