if( !defined($ENV{"QUERY_STRING"})) { # Check for Query String environment &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 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 items, # then you'll have to be a bit more careful... }