# inside your foreach loop before parsing, check if the file does exists if (-e $file ) { # parse the file }else{ print "$file doesn't exists\n"; }