[Catalyst] about req.param
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)); } when visit as test?b=1 it shows $VAR1 = \{ '1' = 'c', 'a' = 'b' }; hmm, a trap I think. need use $c-req-param('a') || ''. something not so good. -- Fayland Lam // http://www.fayland.org/ Foorum based on Catalyst // http://www.foorumbbs.com/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] about req.param
Yes, because it's evaluated in a list context. I prefer doing $c-req-params-{a} for that reason. On 4/11/08, Fayland Lam [EMAIL PROTECTED] 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)); } when visit as test?b=1 it shows $VAR1 = \{ '1' = 'c', 'a' = 'b' }; hmm, a trap I think. need use $c-req-param('a') || ''. something not so good. -- Fayland Lam // http://www.fayland.org/ Foorum based on Catalyst // http://www.foorumbbs.com/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/ -- Tatsuhiko Miyagawa ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] about req.param
On 11/04/2008, Fayland Lam [EMAIL PROTECTED] 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)); } when visit as test?b=1 it shows $VAR1 = \{ '1' = 'c', 'a' = 'b' }; hmm, a trap I think. need use $c-req-param('a') || ''. something not so good. I recall in an earlier thread (or maybe on irc) mst said param() should be deprecated for methods with guaranteed return types - that was why I added param_value(), param_array() and param_list() to FormFu. If this were added to Catalyst, you could do this with no problems... my $test = { a = $c-req-param_value('a'), b = $c-req-param_value('b'), c = $c-req-param_value('c'), }; Carl ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/