Don't be doubly paranoid

  if (! -x $filename) {
    die "File $filename does not exist"
  }
  open(FILE, "predict -f=$filename|") || 
       die "Cannot open: $fiename"
  • The 'open' does the check for existance.
  • The file may be deleted between the two checks.
  • There can be bugs in how 'predict' works.
By the way, watch out!
   -'$filename' may contain special metacharacters.
 
.