Skip to content

Instantly share code, notes, and snippets.

@gideondsouza
Created December 29, 2012 15:41
Show Gist options
  • Save gideondsouza/4407649 to your computer and use it in GitHub Desktop.
Save gideondsouza/4407649 to your computer and use it in GitHub Desktop.
#this is a utility method that will convert a query string into a hash
sub parse_query_str {
my $str = shift;
my %in = ();
if (length ($str) > 0){
my $buffer = $str;
my @pairs = split(/&/, $buffer);
foreach my $pair (@pairs){
my ($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$in{$name} = $value;
}
}
return %in;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment