One of the possible solutions would be use the HTTP::Request::Common module, which exposes some useful functions like GET
, POST
and HEADER
.
Assuming you want to use POST
to send the data to the remote application, you could do:
use HTTP::Request::Common;
use LWP::UserAgent;
my $url = 'http://localhost/cgi-bin/mycgi.pl';
my $xml = "<root></root>";
my $request = POST $url, Content_Type => 'text/xml; charset=utf-8', Content => $xml;
my $ua = LWP::UserAgent->new();
my $response = $ua->request($request);
if ( $response->is_success() ) {
print $response->content();
}
else {
warn $response->status_line, $/;
}
Hope this helps!