在 Perl 中,我们通常使用递归目录遍历,File::Find
并且我们经常使用类似于下面的代码来根据模式查找某些文件。
find(\&filter, $somepath);
sub filter {
my $srcfile = $_;
if -f $srcfile && $srcfile =~ /<CERTAIN PATTERN>/ {
<Some processing which requires a premature exit>
}
}
这通常非常灵活,但有时我们想提前退出查找。Perl 中是否有明确的方法来执行此操作?