in reply to Validating incoming CGI form data
The above code is untested and assumes the use of CGI.use strict; use CGI; my $query=CGI->new(); my %laundry= ( 'name' => '(\w+)', 'number' => '(\d+)', 'choice' => ([ABC]), ); my %laundered_params; foreach my $param (keys %laundry) { die "Parameter $param not present\n" unless my $input=$cgi->param($p +aram); my $regexp=$laundry{$param}; $input =~ /$regexp/; die "Invalid input for $param\n" unless $laundered_params{$param}=$1 +; }
CU
Robartes-
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Validating incoming CGI form data (more concise)
by Aristotle (Chancellor) on May 02, 2003 at 14:44 UTC |