>On 2013-02-17 02:30, Tom Christiansen wrote: >> However, if hitting EOF is an expected and normal event, you >> would not to exit just because you ran out of input. Instead, >> you probably just want to exit an input loop. Immediately >> afterwards you can then test to see if there was an actual >> error that caused the loop to terminate, and act accordingly: >> >> while (<$handle>) { >> # do something with data in $_ >> } >> if ($!) { >> die "unexpected error while reading from $filename: $!"; >> } > I don't like to show a test of such a global. Which one is that? You have no choice. > Only if you already know something went wrong, then you can use the > global's value(s). Actually, you know something went wrong. You got undef back from readline. The question is whether there was an error or whether it was eof. The one and only way to know that is to check $! as the very very very next thing after the failed call. >Maybe test $handle->error? Yesterday I showed that not to work in all cases. --tomThread Previous | Thread Next