- 论坛徽章:
- 1
|
本帖最后由 lockeyou 于 2013-08-20 12:52 编辑
我的程序是借助
my $path = '/usr/db';
find( \&wanted1, $path );
sub wanted1 {
if ( -f $File::Find::name ) {
if ( $File::Find::name =~ /\.php$/ ) { #查找后缀为.php文件
my $kw={'exec'=>0,'evel'=>0,'popen'=>0,'system'=>0,'passthru'=>0,'curl_exec'=>0};
open (FH,"<","$File::Find::name") || die "open file failure.\n";
while (<FH>){
chomp;
my $line = $_;
my $count=0;
foreach(keys(%$kw)){
$kw->{$_}+=$count if $count=$line=~s/$_//g;
}
}
close FH;
my @merge = values(%$kw);
sub add_num{
my$sum=0;
foreach $_(@_){
$sum+=$_;
}
$sum;
}
my $res = add_num(@merge);
if($res > 0){
open (LOG,">>",$initialize_file) || die "open file failure.\n";
print LOG "$File::Find::name&Counts_kw=$res\n";
close LOG;
undef(%$kw);
}
}
}
}
我的程序是查所有php里面的关键字,写入文本,
现在$path 里面有个子目录下的文件我不想查,该怎么办哇
比如\usr\db\test\test1\test2 里面的所有php文件我都不想找里面的关键字,
有没有方法哇
|
|