in reply to Unexpected behavior after passing $query-param('bar') as subroutine parameter

Yes. param is context sensitive. In a scalar context, it returns a single scalar value of the first (arbitrary order) param with that name, or undef showing that nothing has that name. In a list context, it returns a list of all params with that name, which could indeed be an empty list, as you saw.

You are using a list context, and using the result in a list, so an empty list disappears. Had there been multiple elements, you'd be messed up the other way, in that your later parameters would have been pushed out of place the other way.

I'd rewrite that code as:

makeMenuInput(scalar $query->param('category'), scalar $query->param(' +subcategory'),"allon");

-- Randal L. Schwartz, Perl hacker

  • Comment on Re: Unexpected behavior after passing $query-param('bar') as subroutine parameter
  • Download Code