这里的代码部分,我试图使用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;
答案 0 :(得分:6)
您不能将数组分配给散列键,只能分配标量。您的尝试将扩展阵列并发送:
{ "istring" => "text1", "text2" => "texxt3", "text4" => "text5" }
使用数组引用,方法是将“take a reference”操作符放在数组前面:
{ istring => \@data_post }