[英]Using File::Find::Rule to get the list of files in Perl
I am trying to identify the list of all .cpp files in my repository. 我试图识别存储库中所有.cpp文件的列表。 I am using the following script:
我正在使用以下脚本:
use File::Find::Rule;
use strict;
use warnings;
my @files = File::Find::Rule->name('*.cpp');
print Dumper @files;
I get the following output: 我得到以下输出:
$VAR1 = bless( {
'mindepth' => undef,
'maxdepth' => undef,
'extras' => {},
'subs' => {},
'iterator' => [],
'rules' => [
{
'args' => [
'*.cpp'
],
'rule' => 'name',
'code' => 'm{(?-xism:^(?=[^\\.])[^/]*\\.cpp$)}'
}
]
}, 'File::Find::Rule' );
I could not find any references online about fetching the list of files. 我在网上找不到任何有关获取文件列表的参考。
Can someone please point me to how to get the required list? 有人可以指出我如何获得所需清单吗?
Thanks. 谢谢。
单程:
my @files = File::Find::Rule->file()->name('*.cpp')->in('.');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.