ctaustin has asked for the wisdom of the Perl Monks concerning the following question:

I am building a cgi web form that will be used for data requests. The form is nothing more than a series of checkboxes for the users to choose which elements they want in their data pull. I am using a pipe delimited flat file to generate the list of checkboxes. The flat file looks like this:

field|data_field1|value for data field 1 field|data_field2|value for data field 2 type|State=CA|state='CA' type|State=OR|state='OR'
I loop through the file and push the different components into a @fields and @types array so that they can be seperated on the form.
my ($type,$name,$desc)=split/\|/; $x=join ("|", ($name,$desc)); if (lc($type) eq "field"){ push @fields, $x; } elsif (lc($type) eq "type"){ push @types, $x; } ... ... ... foreach $f (@types){ ($name,$desc)=(split/\|/,$f); $desc=~s/\n//g; $name=ucfirst($name); print qq{<tr><td>$name</td> <td><input type="checkbox" name="$name" value="$desc"> +</td> </tr>}; }


What I need to do now if gather up the items that were checked and put them into an email.

Since the list of parameters is ever changing I don't want to hard code the names in. Is there a way to get this list from the form without knowing the parameter names and put the values into the body of an email quickly and efficiently?
Regards

Replies are listed 'Best First'.
Re: Dynamic CGI Form Processing
by cmeyer (Pilgrim) on Jun 14, 2005 at 21:08 UTC

    Look at the documentation for CGI. Look at the $cgi->param() method, especially at what it returns when you pass it no arguments.

    -Colin.

    WHITEPAGES.COM | INC

Re: Dynamic CGI Form Processing
by merlyn (Sage) on Jun 14, 2005 at 21:31 UTC
      The params trick did it:
      @params=$co->param(); foreach $param (@params){ $p=$co->param($param); ... ...
      Thanks for the quick replies.