package parseform;

$parseform_delim = "\n";
sub parseform {
    local($formthing) = @_;	# Expects something like:
				# foo=wow%21&bar=hello&baz=blah

    (@fields) = split('&', $formthing);
    for $f (@fields){

	($name, $value) = split('=', $f);
	    $value =~ y/\+/ /;
	$value =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; # remove % escapes
        if(defined $lookup{$name}){
            $lookup{$name} .= $parseform_delim.$value;
	    }
	else{
          $lookup{$name} = $value;
    }
    }

    %lookup;
}
1;
