foreach my $expect (@expected) { my $received = $q->param($expect); unless (defined $received) { $error .= "Didn't get $expect parameter!\n"; } push @request, $received; } if($error ne "") { # Handle the error here, reprinting the form, # pre-filled with what they've already sent. # Also tell them about all the problems: print $error; }