奇怪的是我,但在下面的代碼沒有我得到任何錯誤,也沒有導致:(無法從文件打印線
use strict;
use warnings;
use File::Find;
my $path = $ARGV[0];
find({ wanted => \&GetappropriateFile }, $path);
my @all_file;
sub GetappropriateFile
{
my $file = $_;
#my @all_file;
# print "$file\n";
if (-f and /traces[_d+]/)
{
print "$file\n";
# push(@all_file,$file);
open(FH, "<", $file) or die "cannot open file:$!\n";
while(my $line = <FH>){
print "$line\n";
$line =~ /Cmd line: com.android.phone/g;
#print "$line\n";
push(@all_file,$file);
last;
#print "$file\n";
}
close(FH);
}
}
至REGx下面的文本文件我用 - > /跡線[_d +]/
traces_com.android.phone_01-22-2014_01-15-54 traces_01-22-2014_06-24-25 traces_com.skype.raider_01-22-2014_01-15-54 traces_com。 android.mms_01-22-2014_01-15-54
我試圖告訴,當我試圖讀取文件沒有輸入輸出 – Maverick
這行'print'$ file \ n「;'實際上產生輸出嗎?它是找到文件,但沒有閱讀它們? –
如果是這樣的話,你可能想打開'$ File :: Find :: name'而不是'$ file'或'$ _',這將是沒有路徑的文件名。 –