如何在 find2perl 和 File::Find 中使用 -not 开关

How to use the -not switch with find2perl and File::Find

需要一些有关 find2perl 的帮助。本来我是在正常表演:

my @files = `find . | grep -v "*.svn"`;

这在源代码树变得相当大之前一直有效,导致上面的速度变慢了很多。所以我切换到这个:

my @files = `find . -not \( -path *.svn -prune \)`;

这很有帮助,但随着时间的推移它也变得相当慢。

我在这里读到 File::Find should/would 比 shelling out 更快,但我似乎无法让 find2perl 为我创建 $wanted 子例程参考。它给了我以下错误:

find2perl . -not \( -path *.svn -prune \) -print
Unrecognized switch: -not

还有其他方法可以做到这一点吗? 感谢您的帮助和建议。

-not 不是 find 的标准选项,您需要使用 !:

find2perl . ! \( -path '*.svn' -prune \) -print

另请注意,您必须引用 *.svn 以防止 shell 对其执行 split+glob。