$content = $ua->request($req);
my $data = $xml->XMLin($content);
This is a bug. $content in this context is an HTTP::Response object, not something which can be blindly passed to XMLin() successfully. You first need to extract the XML from it. eg. by using decoded_content. I'd therefore refrain from calling the response $content in the first place.
Try replacing those two lines with:
my $response = $ua->request ($req);
my $content = $response->decoded_content;
my $data = $xml->XMLin ($content);
That ought to get you a little bit farther along at least.