use Cwd; foreach(@dir) { if (-d$_) { print $_," is a directory.\n"; } else { die("Not a dir '$_', current working directory is: ". cwd()); } }