http://qs321.pair.com?node_id=132455


in reply to When does while() test for defined vs truth

Quoth perlop (update on seeing reply: or maybe perlop2):

....

I/O Operators

....

If and only if the input symbol is the only thing inside the conditional of a "while" statement (even if disguised as a "for(;;)" loop), the value is automatically assigned to the global variable $_, destroying whatever was there previously....

...

In these loop constructs, the assigned value (whether assignment is automatic or explicit) is then tested to see whether it is defined....

....

As with filehandle reads, an automatic "defined" is gener ated when the glob occurs in the test part of a "while", because legal glob returns (e.g. a file called 0) would otherwise terminate the loop....

....