Spot the mistake (solution)

Abigail on 2006-10-06T20:30:24

The bug in the program below (beside the spotted $fh = open (...) instead of open ($fh, ...)) lies in in the true-ness of $ebits.

If there are no errors, Perl will set all bits in $ebits to 0. However, a string where all bits are set to 0 is still true. So, hell will be raised even if there are no errors. And if file descriptors 4 and 5 would be in error, it would not raise the alarm.