<PRE>
# Source for CGI-LIB.PL, by Stephen Brenner:
# ReadParse
# Reads in GET or POST data, converts it to unescaped text, and
# puts one key=value in each member of the list &quot;@in&quot;
# Also creates key/value pairs in %in, using '\0' to separate
# multiple selections
# If a variable-glob parameter (e.g., *cgi_input) is passed to
# ReadParse, information is stored there, rather than in $in, @in,
# and %in.
sub ReadParse {
    local (*in) = @_ if @_;
  local ($i, $loc, $key, $val);
  # Read in text                    #Checks the data-sending method
  if ($ENV{'REQUEST_METHOD'} eq &quot;GET&quot;) {
    $in = $ENV{'QUERY_STRING'};
  } elsif ($ENV{'REQUEST_METHOD'} eq &quot;POST&quot;) {
    read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
         #Reads in CONTENT_LENGTH bytes of STDIN
  }
  @in = split(/&amp;/,$in);       #Splits ordered pairs at the &quot;&amp;&quot; sign
  foreach $i (0 .. $#in) {    #Processes ordered pairs
    # Convert plus's to spaces
    $in[$i] =~ s/\+/ /g;
    # Split into key and value.
    ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.

    # Convert %XX from hex numbers to alphanumeric
    $key =~ s/%(..)/pack(&quot;c&quot;,hex($1))/ge;
    $val =~ s/%(..)/pack(&quot;c&quot;,hex($1))/ge;
    # Associate key and value
    $in{$key} .= &quot;\0&quot; if (defined($in{$key})); # \0 is the multiple
    $in{$key} .= $val;                         # separator
 }
  return 1; # just for fun
}
</PRE>