bazz
08-04-2009, 04:25 AM
Hi.
I have passed a load of params from a form to this script. This script will check them for cleanliness and I want the erroneous values to output in the same order as in the previous form.
This is what I am trying but I have a sneaking feeling that I am making it loop through all the values each time it tries to output any one. Am I correct or os this the correct way to do this?
my %params = $cgi->Vars;
my @acceptable_input = acceptable_values();
my %valid_keys;
foreach my $key ( keys %params ) # loop through all sent params
{
foreach my $column_name(@acceptable_input)
{
my ($field, $label) = each %$column_name;
$valid_keys{$field} = $field;
if ($key eq $valid_keys{$field} )
{
print qq( OK );
}
}
}
bazz
I have passed a load of params from a form to this script. This script will check them for cleanliness and I want the erroneous values to output in the same order as in the previous form.
This is what I am trying but I have a sneaking feeling that I am making it loop through all the values each time it tries to output any one. Am I correct or os this the correct way to do this?
my %params = $cgi->Vars;
my @acceptable_input = acceptable_values();
my %valid_keys;
foreach my $key ( keys %params ) # loop through all sent params
{
foreach my $column_name(@acceptable_input)
{
my ($field, $label) = each %$column_name;
$valid_keys{$field} = $field;
if ($key eq $valid_keys{$field} )
{
print qq( OK );
}
}
}
bazz