Don't use &subroutine; unless you're sure that you want to do that. You very likely want subroutine(); instead.
As for cleaning the code a litte: you could do something like:
Warning: untested code ahead
At least I think it looks a little better :-)my %opts = ( bandwidth => { err => 'Your Chosen Bandwidth Option Does Not Appear To Be Valid. Contact Support For Assistance.', match => qr/^15|0$/, }, support => { err => 'Your Chosen Support Option Does Not Appear To Be Valid. Contact Support For Assistance.', match => qr/^2|0$/, } # etc etc. ); my $error = ''; while (my ($name,$check) = each(%opts)) { unless ($q->param($name) =~ $check->{match}) { $error .= "<p>$check->{err}</p>\n"; } } if ($error) { print_error($error); }
-- Joost downtime n. The period during which a system is error-free and immune from user input.
In reply to Re: Validating incoming CGI form data
by Joost
in thread Validating incoming CGI form data
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |