Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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]
[ambrus]: MLX: if it's a work email, then it's probably not Uncle Sam that matters, but what the account managing server at work thinks your name is. Those can differ. For example, we've had two co-workers with identical real name at one point,
[ambrus]: so one got a stupid suffix in the email account (people have email address based on their real name here usually).

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2017-01-19 14:09 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (170 votes). Check out past polls.