Re: how to send data to a URL?
Tim Allwine <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Message-ID | <[email protected]> |
Andy Lester wrote:
>
> On May 31, 2007, at 5:16 PM, vidals wrote:
>
>> I use LWP all the time for requesting web pages, but can somebody
>> provide some guidance as to how LWP can be used to send data? I'm
>> confused.
>
> Use WWW::Mechanize, which is a wrapper around LWP and includes many
> useful examples of POSTing data.
>
>
Or if you like yours 'neat'
use LWP;
my $ua = LWP::UserAgent->new();
my $req = HTTP::Request->new(POST => 'http://fancywebservice.com');
my $xml = get_xml_data(); # your function here
my $length = length($xml);
$req->content($xml);
$req->header('Content-length' => $length);
my $res = $ua->request($req);
my $response_data = $res->content;
you might want to do a little more reading after this point.
-Tim