foreach my $p (qw(name site siteid ...)) { if ($q->param($p) =~ /\|/) { error("$p has a vertical bar, that's bad"); # or something } }