我的代码几乎取自模块cpan页面:
use strict;
use warnings;
use LWP::Curl;
my $lwpcurl = LWP::Curl->new();
my $referer = 'http://www.example.com/';
my $post_url = 'https://example';
my $key='363073020844984X3v2';
my $hash='73wKwB802h8y26VrmyGD4TIqXSnsV7u39DDOOCd82578t9c92paeBABnMH0ahzp6lzH';
my $action='boot'; # ACTION="info&ipaddr=true&mem=true&hdd=true&bw=true"
my $hash_form = {
'KEY' => $key,
'HASH' => $hash,
'action' => $action,
}
my $content = $lwpcurl->post($post_url, $hash_form, $referer);
print $content;
我收到一个奇怪的语法错误:
syntax error at soluscontrol.pl line 16, near "my "
Global symbol "$content" requires explicit package name at /root/bash-advanced-scripts/soluscontrol.pl line 16.
Global symbol "$hash_form" requires explicit package name at /root/bash-advanced-scripts/soluscontrol.pl line 16.
Global symbol "$content" requires explicit package name at /root/bash-advanced-scripts/soluscontrol.pl line 17.
Execution of /root/bash-advanced-scripts/soluscontrol.pl aborted due to compilation errors.
我无法识别错误的来源。
答案 0 :(得分:5)
从第10行开始的陈述缺少其终止分号。
my $hash_form = {
'KEY' => $key,
'HASH' => $hash,
'action' => $action,
}
应该是
my $hash_form = {
'KEY' => $key,
'HASH' => $hash,
'action' => $action,
};