#split the query string by key/value pairs
my @unparsed = split(/&/, $query);
for $pair(@unparsed) {
# split the key and value for each pair
my ($key, $value) = split(/=/, $pair);
#substitue pluses for spaces
if ($value =~ /\+/) { $value =~ s/\+/ /g; }
#look for hex values (this could be a better regex)
while ($value =~ /\%((\d¦\w)(\d¦\w))/g) {
my $val = $1;
my $hex_val = hex($val);
#replace all occurrences of the hex value with the character
$value =~ s/%$val/chr($hex_val)/eg;
}
#store results in a hash
$params{$key} = $value;
}