$input=; # read form data from stdin $input =~ s/\s*$//; # chop trailing CR/LF/space 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 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 equals sign,into # name and value strings. # Then decode the strings. $name =~ s/\+/ /g; # convert +'s to spaces $name =~ s/%(..)/pack("c",hex($1))/ge; # convert hex to Latin-1 $value =~ s/\+/ /g; # convert +'s to spaces $value =~ s/%(..)/pack("c",hex($1))/ge; # convert hex 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... }