in reply to Bad file descriptor
The docs for readline are wrong for two reasons:
It's on my todo list to fix the documentation.
For handles other than ARGV, you want
while (!eof($fh)) { defined( $_ = <$fh> ) or die("Can't readline: $!\n"); ... } [download]