in reply to Testing filehandles

To further clarify, the
while (<FH>) { ... }
construct is magical. Perl sees that, and does something like this:
while (defined ($_ = <FH>)) { ... }
Thus, use
while (($_ = <STDIN>) ne "\n"){ ... }
to properly emulate this behavior. Also, I believe that use warnings would have detected improper use of numeric comparison, mate.


Who is Kayser Söze?
Code is (almost) always untested.

Replies are listed 'Best First'.
Re: Re: Testing filehandles
by Anonymous Monk on Jan 03, 2004 at 22:49 UTC
    Or alternatively...
    while (<STDIN>) { last if $_ eq "\n"; }