你不想File::Find在这里。
看看opendir和readdir。
use warnings;
use strict;
# you probably want to use the abs. path
my $dir = "testdir";
opendir(my $dh, $dir);
# grep out directory files from the list of files to work on
# this will also skip "." and "..", obviously :)
my @files = grep { ! -d } readdir $dh;
closedir $dh;
# change to the given directory, as readdir doesn't return the relative path
# to @files. If you don't want to chdir, you can prepend the $dir to $file as
# you operate on the $file
chdir $dir;
for my $file (@files) {
# do stuff..
# E.g., "open my $fh, ">>", $file;", etc
print $file, "\n";
}
输出
$ ./test.pl
a_file.txt
b_file.txt
c_file.txt