foreach my $dir (@DIRS) { warn "Directory $dir not found!\n" and next unless -d $dir; # # work with existing directory here # }