perl sting 和 hash读取问题 如果传递到sub

来源:百度知道 编辑:UC知道 时间:2024/06/06 08:43:42
我得值是 {name => '1 usr/bin/perl t-shirt',price => '14.99',itemID => 1001},{name => '1 usr/bin/perl t-',price => '14.99',itemID => 1002}

请问是sting还是hash? 如果是string得话。如何一次传递到sub里? $readall = $_; ? 是这样吗

@readall = @_; 应是正解。可就是无法测试成功。 $readall = $_; 好像没有读到正确数据。谁能帮帮我啊。 这个数据需要传递到一个sub里。
这是个简单测试程序。但是出错了。不知道问题在哪

#!/usr/bin/perl
print "Pragma: no-cache\n";
print "Content-type:text/html\n\n";
my $alltata = "{quantity => 1,name => 'ddd',price => 15,prod_subtotal => 15,itemID => '15'}";
say_hello();
sub say_hello {
my $alltata1 = $_;
print "Hello, World! <br>@alltata1<br><br>\n";
}

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.

程序修改为:
#!/usr/bin/perl
print "Pragma: no-cache\n";
print "Content-type:text/html\n\n";
my $alltata = "{quantity => 1,name => 'ddd',price => 15,prod_subtotal => 15,itemID => '15'}";
say_hello( $alltata );
sub say_hello {
my $alltata1 = shift;
print "Hello, World! <br>$alltata1<br><br>\n";
}