in reply to Explaining Perl truth to beginners

For beginners: the output of a boolean operation is reliably interpreted as true or false. Everything else should be tested by comparison.

The one idiomatic exception I can think of is

while (<INPUT>) { ...
which has an implicit boolean test in it. Nothing else springs to my mind.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Explaining Perl truth to beginners
by ysth (Canon) on Nov 22, 2005 at 12:51 UTC
    which has an implicit boolean test in it.
    Actually, an implicit defined() test in it:
    $ perl -MO=Deparse -e'while (<INPUT>) {}' while (defined($_ = <INPUT>)) { (); } -e syntax OK
    so that e.g. a 0 with no following newline at the end of a file still goes into the body of the loop.