in reply to More efficient reading of forms in CGI

you could also use the following code snippet to retrieve all the field name and value pairs that are passed in from the form into a hash:
my %pairs = $cgi->Vars();
Now it a field called "name" was in your form and it contains the value 'bob' you could do:
my $name = $pairs{name}; now $name will contain 'bob'

Replies are listed 'Best First'.
Re: Re: More efficient reading of forms in CGI
by bassplayer (Monsignor) on Sep 30, 2003 at 14:41 UTC
    This method also elegantly handles input fields with multiple values, such as checkboxes and pulldown menus (multiple select). If the name parameter that bear0053 describes is from a set of checkboxes, and the names Bob and Joe were selected, $pairs{name} would contain 'Bob' and 'Joe' separated by NULL character ( \0 ). Very easy to parse, if needed. I think that your way will squash all but the first value (not very nice if you're Joe).

    You will need CGI version 2.53 or higher to use Vars().

    bassplayer