Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^4: RFC: Class::CGI

by Aristotle (Chancellor)
on Apr 08, 2006 at 09:16 UTC ( #542027=note: print w/replies, xml ) Need Help??

in reply to Re^3: RFC: Class::CGI
in thread RFC: Class::CGI

Being able to specify an arrayref so that you can pass user-defined additional parameters is a good idea anyway, but the need for it could be obviated in many cases. The following should be enough:

use Class::CGI handlers => { invoice_date => 'My::Date::Handler', sales_date => 'My::Date::Handler', };

This can work if you just pass the parameter name to the handler constructor. Users can then create a convention based on the name and avoid the need for configuration:

package My::Date::Handler; use Carp; use My::Date; sub new { my $class = shift; my ( $cgi, $param_name ) = @_; $param_name =~ s/_date\z// or croak "Profile name expected to end in '_date': $param_name +"; my %date = map { $_ => scalar $cgi->raw_param( $param_name . '_' . $_ ) } qw( month day year ); return My::Date->new( %date ); } 1;

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^5: RFC: Class::CGI
by Ovid (Cardinal) on Apr 08, 2006 at 16:41 UTC

    I'm not sure about the arrayref idea, but making the parameter name available is so obvious that I'm calling that a feature request. I'll add it.


    New address of my CGI Course.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://542027]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2018-02-18 23:08 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (257 votes). Check out past polls.