- 论坛徽章:
- 0
|
#!/usr/bin/perl
use File::Find;
find(\&filefind,"/opt/checkpath/test");
sub filefind{
my $findfile = $File::Find::name;
if (-T $findfile){
open(filehand,"$findfile");
my $linenum = 1 ;
while ($line=<filehand>)
{ print "the config file","\"$findfile\""," line ","$linenum"," includes a invaild path:\n","$line" if $line=~/\/home\/dsn/;
$linenum = $linenum + 1;
}
close(filehand);
}
elsif (-l $findfile){
my $test = `ls -l $findfile | awk '{print \$9,\$10,\$11}'`;
print "test file is $test\n";
print "the file ","\"$findfile\"","is a link file ","and includes a invaild path:\n $test\n",if $test = ~/\/home\/dsn/;
}
}
为什么这个程序的上部分一样的匹配不会出现这样的数字问题?
这个程序运行的结果为:
[root@rhas3 perl]# perl test.pl
the config file"/opt/checkpath/test/file1" line 1 includes a invaild path:
/home/dsnsv00disk003
the config file"/opt/checkpath/test/file1" line 3 includes a invaild path:
test /home/dsnsv10/disk010
test file is /opt/checkpath/test/BLOCK -> /mnt/home/dsnsv00/disk003
the file "/opt/checkpath/test/BLOCK"is a link file and includes a invaild path:
4294967295
[ 本帖最后由 sousi 于 2006-12-18 22:38 编辑 ] |
|