sub open_directory {
my $directory = shift @_;
my @files =();
opendir (my $dh, $directory) or die "Couldn't open dir '$directory' : $!";
my @all_files = readdir $dh;
closedir $dh;
foreach my $files(@all_files){
while($files =~ /\.htm/){
push(@files);
}
}
return @files;
}
的錯誤是在代碼push(@files);
的錯誤是: Useless use of push with no values
排序文件名到一個數組使用Perl和正則表達式
我想要處理的的.htm
或.html
結束名稱中的文件在@files
數組中使用正則表達式/\.htm/
請幫助我。
有錯誤消息意味着你忘了指定_what_挺進陣列。想想看。 – Mat 2013-05-03 08:26:07
另外,'while'應該是一個'if'。 – amon 2013-05-03 08:28:04
我想這樣的事情應該工作? 'push(@files,$ files);' – 2013-05-03 08:31:23