[Catalyst] Re: about req.param
Jonathan Rockway
jon at jrock.us
Fri Apr 11 19:30:10 BST 2008
* On Fri, Apr 11 2008, Fayland Lam wrote:
> Fayland Lam wrote:
>> code as follows:
>>
>> sub test : Local {
>> my ($self, $c) = @_;
>> my $test = {
>> a => $c->req->param('a'),
>> b => $c->req->param('b'),
>> c => $c->req->param('c'),
>> };
>> $c->res->body(Dumper(\$test));
>> }
>>
>
>
> well, this is OK
>
> sub test : Local {
> my ($self, $c) = @_;
>
> my $test = {
> a => $c->req->params->{'a'},
> b => $c->req->params->{'b'},
> c => $c->req->params->{'c'},
> };
> $c->res->body(Dumper(\$test));
> }
Yes, param only exists so you can pass $c->req to a function expecting a
CGI object. (It's for compatibility, not for use in new applications.)
If you really want to use a function call instead of a hash lookup,
apply this role to the request class:
http://git.jrock.us/?p=MooseX-Param-Safe.git;a=blob;f=lib/MooseX/Param/Safe.pm;hb=HEAD
Regards,
Jonathan Rockway
--
print just => another => perl => hacker => if $,=$"
More information about the Catalyst
mailing list