in reply to opening missing file inside eval statement

Check the return (error) status of open with $! (Tip #7 from Basic debugging checklist).
I think die statements all over the place diminish code readability myself
autodie was created to address that issue.

Re-writing your code with more modern/robust style:

open my $fh, '<', $file or die "can't find input file $!";

Replies are listed 'Best First'.
Re^2: opening missing file inside eval statement
by oko1 (Deacon) on Jan 08, 2011 at 23:30 UTC

    Just a personal preference on my part: I never put anything other than "$filename: $!\n" in the 'die' string - because it can lead to nonsense messages like this:

    test.txt: cannot find input file Is a directory test.txt: cannot find input file Permission denied

    etc.

    -- 
    Education is not the filling of a pail, but the lighting of a fire.
     -- W. B. Yeats
      Agreement, though I like to say "opening '$filename': $!\n". This way, I
      • know where the problem was (as opposed to writing or positioning the file)
      • can see if there's a null or CRLF terminated string as the filename.