I'm looking for a way in Perl to list the plain files of a directory. Files only, no directories.
You need to use opendir
, readdir
and closedir
functions in conjunction with -f
file test operator:
opendir(my $dh, $some_dir) || die $!;
while(my $f = readdir $dh) {
next unless (-f "$some_dir/$f");
print "$some_dir/$f\n";
}
closedir $dh;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With