opendir my $dh4, $a_directory or die "can't open directory $dh4:$!"; while (my $this_file = readdir $dh4) { next if ($this_file =~ /\.log$/); #skip all log files next if (-d "$dh4/$this_file"); #skip all directories print "$this_file is an extra file: $dh4/$this_file\n"; }