解决方法
使用-d文件检查运算符:
#!/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\n"; } closedir $DIR;