PracticeDev/study_perl/list_director.pl

19 lines
339 B
Perl
Raw Permalink Normal View History

2022-12-20 17:31:11 +08:00
#!/usr/bin/perl
use strict;
use warnings;
use Path::Tiny;
my $dir = path('/var','log'); # /var/log
# Iterate over the content of foo/bar
my $iter = $dir->iterator;
while (my $file = $iter->()) {
# See if it is a directory and skip
next if $file->is_dir();
# Print out the file name and path
print "$file\n";
}