in reply to CGI:Application and HTML::Template parameter passing

the problem is that you are using numeric comparison (==) when you need string comparison (eq), so the contents of $q->param('userid') always evaluates to true regardless if it's empty or not. change your code like this:

if ($q->param('userid') eq '') { $self->_create_user(); } else { $self->_update_user(); }

see also the tutorials here on PerlMonks that cover the various ways Perl test for true/false.

also here is how you could debug input parameter passing in your CGI::Application modules:

sub maintain_user { my $self = shift; my $q = $self->query; use Data::Dumper; return Dumper $q; }
:)))))

Replies are listed 'Best First'.
Re^2: CGI:Application and HTML::Template parameter passing
by meraxes (Friar) on Sep 03, 2007 at 01:14 UTC

    In addition to the above and since you're using the ValidateRM plugin (hoorah!) you may want to also consider using $result->valid('userid') instead of $q->param('userid') to make sure you're taking advantage of all the goodes that ValidateRM provides.

    If any of the params are using a filter (like trim or digit or a custom one) or if you eventually start using filters, doing this will stop you from having to change anything later. Filters are definately good to clean your data up.

    --
    meraxes