# cgi-lib.pl is an external module containing one function called # ”ReadParse” which extracts field name-value pairs from a form and # unescapes them returning the data in an associative array called # ”in” sub ReadParse { # Retrieve GET or POST form data if ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer=$ENV{'QUERY_STRING'}; } else { $content_length=$ENV{'CONTENT_LENGTH'}; for ($count=0; $count<$length; $count++) { $buffer.=getc; } } # Split the name-value pairs @formdata = split(/&/, $buffer); foreach $pair (@formdata) { ($name, $value) = split(/=/, $pair); # Unescape data in value # convert plus signs back to spaces $value =~ tr/+/ /; # convert hexadecimal representations back to ASCII characters $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # now put the name-value pair into the associative array $in{$name} = $value; } } return 1;