我有一个函数低于在Perl将数组传递给Perl子时,“参数太多”?
sub create_hash()
{
my @files = @_;
foreach(@files){
if(/.text/)
{
open($files_list{$_},">>$_") || die("This file will not open!");
}
}
}
我调用这个函数传递一个数组参数如下图所示:
create_hash(@files2);
数组中它已得到约38的值。 但我得到的编译错误:
Too many arguments for main::create_hash at ....
什么是错了,我现在做的吗?
我的perl版本是:
This is perl, v5.8.4 built for i86pc-solaris-64int
(with 36 registered patches, see perl -V for more detail)
取下'()'? (如'sub create_hash {..}') – 2012-08-13 06:53:41
如果你调用你的函数会发生什么:create_hash(files2); (不带“@”符号) – Arfeen 2012-08-13 06:54:38
@ pst如果我删除它们错误是:Array找到操作员预期在process.pl第71行,在行尾 (您需要预先声明create_hash?) 语法错误在进程.pl第71行,在“create_hash @ files2”附近 – Vijay 2012-08-13 06:59:34