neo*_*neo 0 perl post lwp lwp-useragent
这是代码部分,我试图使用LWP POST整个数组,但服务器只接收第一行数组(0索引)而其他人没有收到发送到服务器,请指导我做错了
$data_post[0] = "text1";
$data_post[1] = "text2";
$data_post[2] = "texxt3";
$data_post[3] = "text4";
$data_post[4] ="text5";
my $ua= LWP::UserAgent->new();
my $response = $ua->post( $url, { 'istring' => @data_post} );
my $content = $response->decoded_content();
my $cgi = CGI->new();
print $cgi->header(), $content;
Run Code Online (Sandbox Code Playgroud)
您不能将数组分配给散列键,只能指定标量.您的尝试将扩展阵列并发送:
{ "istring" => "text1", "text2" => "texxt3", "text4" => "text5" }
Run Code Online (Sandbox Code Playgroud)
通过在数组前放置"take a reference"操作符来使用数组ref:
{ istring => \@data_post }
Run Code Online (Sandbox Code Playgroud)