in reply to Re^2: Doubt on defined-ness
in thread Doubt on defined-ness

It seems perl applies its magic test for definedness to any while that involves a filehandle (at least, I couldn't find a case where it didn't apply).
$ perl -MO=Deparse -e 'while (<>) {} while ( <ARGV> ) {} while ( $_ = +<> ) {} while ( $x = <> ) {}' while (defined($_ = <ARGV>)) { (); } while (defined($_ = <ARGV>)) { (); } while (defined($_ = <ARGV>)) { (); } while (defined($x = <ARGV>)) { (); } -e syntax OK


Unless I state otherwise, all my code runs with strict and warnings

Replies are listed 'Best First'.
Re^4: Doubt on defined-ness
by ikegami (Patriarch) on Jun 18, 2008 at 22:54 UTC

    That's almost the limit. Anything more complex doesn't add a defined.

    >perl -MO=Deparse -e"while (<FILE> && foo()) {}" while (<FILE> and foo()) { (); } -e syntax OK