in reply to Re^3: Playing with non-localized $_ in nested loops.
in thread Playing with non-localized $_ in nested loops.

<DATA>; print $_; __DATA__ This is a test. __OUTPUT__ Use of uninitialized value in print at mytest.pl line 8, <DATA> line 1 +.

Hmm... You're right. There goes that theory. ;) I was erroneously sure that the while() loop's conditional had nothing to do with the fact that the diamond operator feeds $_. Thanks for the enlightenment. :D


Dave

Replies are listed 'Best First'.
Re^5: Playing with non-localized $_ in nested loops.
by ysth (Canon) on Aug 23, 2004 at 05:23 UTC
    There are actually two pieces of dwimmery going on; first, if a readline or a glob is the only thing in a while condition (whether a statement modifier or while statement), it gets an implicit $_ =. Next, if a while condition is a scalar assignment from a readline, readdir, glob, or each, the whole condition gets an implicit defined() wrapped around it, so the loop continues on "0" or "".
Re^5: Playing with non-localized $_ in nested loops.
by Aristotle (Chancellor) on Aug 23, 2004 at 10:06 UTC

    That is why, in the node you referenced, I was talking about while(<FH>). Invoking the DWIMmery really does require this entire combination of operations.

    Makeshifts last the longest.