saintmike has asked for the wisdom of the Perl Monks concerning the following question:

Is it a bug or a feature that the eval in
eval { @ARGV = qw(/nowhere); while(<>) {} }; if($@) { print "There was an error!\n"; }
doesn't catch the error thrown by while(<>)?

The above doesn't print "There was an error!" as I'd expected, but "Can't open /nowhere: No such file or directory at ./t line 6." instead. Tested with perl 5.8.4.

Replies are listed 'Best First'.
Re: while(<>) throws uncatchable errors
by merlyn (Sage) on Jan 27, 2006 at 21:33 UTC
      D'oh! You're correct, and no warnings inside the eval block suppresses the warning. Thanks!