$input=<STDIN>;                            # read FORM data from stdin
chop($input); chop($input);                # chop CR/LF trailing characters:
                                           # recall that the data sent by a client
                                           # is always terminated by a single line
                                           # containing only a CRLF pair. This
                                           # must be removed, since it is not
                                           # part of the message body.
                                           # Check for unencoded equals sign -- if
                                           # there are none, the string didn't
if( $input !~ /=/ ) {                      # come from a FORM, which is an error.
    &pk_error("Query String not from FORM\n");
}
                                           # If we get to here, all is OK. Now
@fields=split("&",$input);                 # split data into separate name=value
                                           # fields(@fields is an array)
 
#   Now loop over each of the entries in the @fields array and break
#   them into the name and value parts. Then decode each part to get
#   back the strings typed into the form by the user

foreach $one (@fields) {
   ($name, $value) = split("=",$one);      # split,at the equals sign,into 
                                           # the name and value strings. Next,
                                           # decode the strings.
   $name  =~ s/\+/ /g;                     # convert +'s to spaces
   $name  =~ s/%(..)/pack("c",hex($1))/ge; # convert URL hex codings to Latin-1
   $value =~ s/\+/ /g;                     # convert +'s to spaces
   $value =~ s/%(..)/pack("c",hex($1))/ge; # convert URL hex codings to Latin-1

   #    What you do now depends on how the program works. If you know that each
   #    name is unique (your FORM does not have checkbox or SELECT items that
   #    allow multiple name=value strings with the same name) then you can place
   #    all the data in an associative array (a useful little perl feature!):

   $array{"$name"} = $value;

   #    If your form does have SELECT or <INPUT TYPE=checkbox..> items, 
   #    then you'll have to be a bit more careful...

}
