开发者

How do I search a directory for all .XXX files and get a list of them in Perl?

I need to search in a directory for all the files that end in .123.

How do I (using Perl) get a list of开发者_高级运维 those files?


Simply:

@files = glob "$dirname/*.123";


One way is to use glob:

use warnings;
use strict;

my @files = grep { -f } glob '*.123';


glob should do the job.
If you want to search recursively, you can use File::Find.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜