标题: 怎么实现遍历目录操作啊 [打印本页] 作者: wg5 时间: 2003-04-26 14:59 标题: 怎么实现遍历目录操作啊 急,求助:!! 作者: deathcult 时间: 2003-04-28 01:10 标题: 怎么实现遍历目录操作啊 use File::Find module作者: terminate 时间: 2003-05-06 01:06 标题: 怎么实现遍历目录操作啊 use File::Find作者: apile 时间: 2003-05-06 10:48 标题: 怎么实现遍历目录操作啊 #!/usr/bin/perl
&find_dir("/"
sub find_dir(){
local($dir) = @_;
opendir(DIR,"$dir"
local @files =readdir(DIR);
closedir(DIR);
for $file (@files){
next if($file=~m/\./ || $file =~m/\.\./);
next unless(-d "$dir/$file"
print "--$dir directory $file\n";
print "----Inside directory $dir/$file\n";
open_dir("$dir/$file"
}
}
不用File::Find moudle的方式...
這兒只是一個找尋所有目錄的例子...
你自己加上你要找的檔名就 ok了...作者: whn3375 时间: 2003-05-07 16:15 标题: 怎么实现遍历目录操作啊 1. it seems the last line should be like "find_dir("$dir/$file""
2. I tried the usual way like "&find_dir("/"", it works very well. But, if change it into "&find_dir("~whn/"" or "&find_dir("/public/home/whn/"" or anything like these, get nothing. why?