in reply to Passing undefined values to package

Since checked is only checking for a scalar, the simplest solution would be this:

Validate->checked( scalar $query->param( 'method' ), 1 );
Without the scalar, the call to param happens in list context, so it returns the empty list, (), which gets lost. By forcing a scalar context then param returns undef.

% perl -de 1 Loading DB routines from perl5db.pl version 1.23 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> use CGI 'param' DB<2> @x = param( 'foo' ) DB<3> @y = scalar param( 'foo' ) DB<4> x @x empty array DB<5> x @y 0 undef DB<6> p scalar @x 0 DB<7> p scalar @y 1

the lowliest monk

Replies are listed 'Best First'.
Re^2: Passing undefined values to package
by bradcathey (Prior) on Aug 04, 2005 at 13:43 UTC

    Wow, how 'fundamental' is that?! I think I read about scalar in the first 5 minutes of my first Perl book. But how soon we forget. Thanks, it worked great and required the least amount of changes to my code.


    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot