我有一個函數低於在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