|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re^2: Unexpected CGI param behaviorby ikegami (Pope) |
| on Jun 24, 2008 at 20:39 UTC ( #693825=note: print w/ replies, xml ) | Need Help?? |
|
You have it backwards, as far as I'm concerned. Your snippet would still fail without wantarray. Without wantarray, my $scalar = $cgi->param('foo'); would *also* fail. That's the case for every function that returns a list. Perl can't return a list in scalar context, so param must necessarily return something different in scalar context. wantarray simply helps return a meaningful value instead of junk. Since param returns a list, feel free to always call param in list context if you want to avoid the issue.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||