# Read all CGI vars into an associative array. # If multiple input fields have the same name, they are concatenated into # one array element and delimited with the \0 character (which fails if # the input has any \0 characters, very unlikely but conceivably possible). # This is a simple version, that assumes a request method of GET. sub getcgivars { local(%in) ; local($name, $value) ; # Resolve and unencode name/value pairs into %in foreach (split(/[&;]/, $ENV{'QUERY_STRING'})) { s/\+/ /g ; ($name, $value)= split('=', $_, 2) ; $name=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ; $value=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ; $in{$name}.= "\0" if defined($in{$name}) ; # concatenate multiple vars $in{$name}.= $value ; } return %in ; }