develooper Front page | perl.beginners | Postings from January 2002

RE: What's wrong with this?

Thread Previous | Thread Next
Jeff 'japhy' Pinyan
January 31, 2002 06:48
RE: What's wrong with this?
Message ID:
On Jan 31, Gary Hawkins said:

>> >>   for $field (param()) {
>> >>     print "$field => ", param($field), "<br>\n";
>> >>   }
>> >
>> >How can the param's be placed into a new hash?
>> has a Vars() method, I believe, which returns a hash.
>>   use CGI;
>>   my $q = CGI->new;
>>   $data = $q->Vars;
>>   print $data->{field};  # etc.
>> But note that this can cause annoyances when you have multiple fields of
>> the same name (like checkboxes).  The values will be \0-separated.
>Fields are all unique.  I read the Vars section of 'perldoc CGI', but didn't
>figure out how to use it.  Wound up with below, maybe some sort of better way,
>not sure.  Reasons for wanting to do this:

Fields are not all unique.

  <input type="checkbox" name="ice_cream" value="chocolate"> Chocolate
  <input type="checkbox" name="ice_cream" value="vanilla"> Vanilla
  <input type="checkbox" name="ice_cream" value="strawberry"> Strawberry

If all three boxes are checked, the query string (or information coming on
STDIN) will include


So code that does:

  $form{$field} = $val;

is broken.

Jeff "japhy" Pinyan
RPI Acacia brother #734
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About