Description: |
This sub takes a HTTP::Request, and returns a hash data structure that contains all form fields. If you have a form field named "blah", and the returned hash is stored in $form_data, then you can get the value for blah through $form_data->{"blah"}.
The asumption is that the form use multipart/form-data encoding. The code is something I use, and not heavily tested with differnt situations. |
sub analyze_request {
my $req = shift;
my $form_data;
for my $part ($req->parts()) {
if (my $content_disposition = $part->headers->header("Content-
+Disposition")) {
if ($content_disposition =~ /^form-data; name=\"(.*?)\"/)
+{
$form_data->{$1} = $part->content();
}
}
}
return $form_data;
}
|