.... while (my $file = readdir(DIR)) { print "$file\n"; if ($file) { ...