开发者

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

开发者 https://www.devze.com 2023-02-16 22:09 出处:网络
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:

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

精彩评论

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