if( !defined($ENV{"QUERY_STRING"})) { # Check for Query String variable
    &pk_error("No Query String\n");   # variable: if absent, then error.
}
$input=$ENV{"QUERY_STRING"}           # get form data from query string
                                      # Check for unencoded equals sign. 
                                      # If there are none, the string 
if( $input !~ /=/ ) {                 # didn't 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 hex codes to Latin-1
   $value =~ s/\+/ /g;                # convert +'s to spaces
   $value =~ s/%(..)/pack("c",hex($1))/ge; 
                                      # convert hex codes 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...

}

