On Tue, Oct 21, 2003 at 02:10:15PM +0200, Matthias Urlichs wrote: > Hi, Steve Kemp wrote: > > > The following change makes the code work as expected: > > Your change works as expected, but only because the file has just one line. > It's not a general solution. > > The general solution is not to use $! as an error indicator in perl. That > doesn't work reliably. Likewise, you can't use 'errno' as an error > indicator in C. _Always_ check the return value. [snip]
IMHO the return value is the most reliable error indicator (in Perl). The <> operator returns an undefined value if it is either EOF or an error occurred; blank lines are returned as 0-length strings (not the same as an undefined value). T -- Just because you can, doesn't mean you should.