Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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.


Comment on Re^4: RFC: Class::CGI
Select or Download Code
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.

    Cheers,
    Ovid

    New address of my CGI Course.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://542027]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2014-08-31 04:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls