问题
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?
回答1:
Simply:
@files = glob "$dirname/*.123";
回答2:
One way is to use glob:
use warnings;
use strict;
my @files = grep { -f } glob '*.123';
回答3:
glob should do the job.
If you want to search recursively, you can use File::Find.
来源:https://stackoverflow.com/questions/5300825/how-do-i-search-a-directory-for-all-xxx-files-and-get-a-list-of-them-in-perl