File::Find::Rule有這些選項,它有一個命令行程序findrule。
如果你想用File :: Find來做到這一點,你可以通過檢查文件的深度和設置$File::Find::prune
來實現maxdepth當你太深了。 mindepth是相似的,但你早期從你的函數返回。今天早上我很懶,所以我會把編碼留給其他人。
更新:其他人做了編程,即File :: Find :: Rule。 Here's the code they use。
my $maxdepth = 2;
my $mindepth = 2;
my $topdir = "something/something/something";
sub wanted {
# figure out the relative path and depth
my $relpath = $File::Find::name;
$relpath =~ s{^\Q$topdir\E/?}{};
my $depth = File::Spec->splitdir($relpath);
defined $maxdepth && $depth >= $maxdepth
and $File::Find::prune = 1;
defined $mindepth && $depth < $mindepth
and return;
...your code goes here...
}
find \&wanted, $topdir;
我不知道答案,但我喜歡你的問題ID以'1337'開頭。 :) – memowe
文檔中均未提及。你爲什麼不試試看? – ikegami
@ikegami:我試過了。交換機無法識別。 – Zaid