Created
December 29, 2012 15:41
-
-
Save gideondsouza/4407649 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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