if (-d $d) { open FILE, "$d/$f" or die "Open failed"; } else { die "No directory $d"; }