Skip to content
Snippets Groups Projects
Commit 3aedf7f4 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Added a function to parse keypair strings

parent 5fbdb0b8
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ our (@ISA,@EXPORT,@EXPORT_OK);
@EXPORT_OK = qw(
parseFormContent
parseURIQuery
parseKeyPairString
);
......@@ -264,5 +265,28 @@ sub booleanize
}
# Function to parse a keypair string and return a hash
sub parseKeyPairString
{
my $str = shift;
my %res;
# Grab components
my @keyPairs = split(/\s+/,$str);
# Loop with the components in sets of name & value
foreach my $item (@keyPairs) {
my ($name,$value) = split(/=/,$item);
# Unescape name value pair
$value =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
# Add to hash
$res{$name}->{'value'} = $value;
push(@{$res{$name}->{'values'}},$value);
}
return \%res;
}
1;
# vim: ts=4
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment