my @varnames = qw( Var1 Var2 Var3 ); my %params; @params{@varnames} = map { $cgi->param($_) } @varnames; if (grep { !defined $params{$_} || $params{$_} eq '' } @varnames) { &complain; } # Now, at this point, you have read in all your parameters # and verified that each is defined as well as not the # empty string. # Do other stuff here.