可能这可以帮助你:
#!/usr/bin/perl -w
use strict;
use HTTP::Request::Common;
require LWP::UserAgent;
my $usr = 'alexis';
my $pass = 'alexispass';
my $URL = 'http://10.64.1.1:80/CGI/Execute';
my $ua = new LWP::UserAgent;
$ua->timeout(20);
my $request = POST $URL,
Content_Type => [ 'Content_Type here' ],
Content => [ 'Content here' ];
$request->authorization_basic($usr, $pass);
my $response = $ua->request($request);
print $response->content;
此脚本使用来自 HTTP::Request::Common 的 POST() 函数。如果我理解正确,那部分 POST 请求应该如下所示:
my $request = POST $URL,
[ XML => '<setBackground><background><image>http://10.64.2.2/7945-65 NFullSize.png</image><icon>http://10.64.2.2/7945-65/NThumSize.png</icon></background></setBackground>'
];
该请求创建对象,它看起来像这样:
POST http://10.64.1.1:80/CGI/Execute
Content-Length: 66
Content-Type: application/x-www-form-urlencoded
XML=<setBackground><background><image>http://10.64.2.2/7945-65 NFullSize.png</image><icon>http://10.64.2.2/7945-65/NThumSize.png</icon></background></setBackground>