给定一个列表,我有尝试多次调用函数的代码。我有一个for()
循环,然后在循环内调用该函数。但是在函数调用的行中,我收到一个奇怪的错误:
[Thu Aug 8 08:31:37 2013] x.cgi: "my" variable $_ masks earlier declaration in same statement at /usr/home/x/public_html/cgi-bin/x.cgi line 310.
[Thu Aug 8 08:31:37 2013] x.cgi: "my" variable $_ masks earlier declaration in same statement at /usr/home/x/public_html/cgi-bin/x.cgi line 310.
该错误很奇怪,因为该行根本没有 a my
。
这是我的代码,使用 perl 5 运行。
sub cgiPrintForm {
my $fh = shift;
for (qw!betatest subscribe fname lname position department company address1 address2 city province postalcode country phone fax email hearofus comments!)
{
print $fh "\n$_: ",param($_) if defined(param($_));
}
print $fh
"\nReferer: ",referer(),
"\nRemote Host: ",remote_host(),
"\nRemote IP: ",remote_addr(),
"\nRemote Ident: ",remote_ident(),
"\nUser Agent: ",user_agent(),"\n";
}
显然 Perl 的一些魔法出了问题,而自动my
的把我弄乱了。