Use the-d
file check operator:
#!/usr/bin/perl
use strict;
use warnings;
use autodie;
my $path = $ARGV[0];
die "Please specify which directory to search"
unless -d $path;
opendir( my $DIR, $path );
while ( my $entry = readdir $DIR ) {
next unless -d $path . '/' . $entry;
next if $entry eq '.' or $entry eq '..';
print "Found directory $entry
";
}
closedir $DIR;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…