in reply to Re^2: <STDIN> not initializing $_
in thread <STDIN> not initializing $_

Update: Ignore this post. I read "and a" instead of "from a".

It is added when the while/until condition is a scalar assignment

As far as I can tell, that's not true. The following prints nothing:

perl -le"while ($a=0) { print 'ysth is right'; last }"

Tested with Perl 5.6.0, 5.6.1, 5.8.0, 5.8.8, 5.10.0.

Replies are listed 'Best First'.
Re^4: <STDIN> not initializing $_
by stiller (Friar) on May 01, 2008 at 05:39 UTC
    An extra edge case:
    perl -le'while($a = 0){print "$a ok\n"; last }' # perl -le'while($a = 1){print "$a ok\n"; last }' # prints 1 ok
    But the "implicit test for defined" is built into the while( ) by language design, there is no extra magic about that in any context?
Re^4: <STDIN> not initializing $_
by mscharrer (Hermit) on May 01, 2008 at 07:33 UTC
    You missed the most important part of the quote:
    It is added when the while/until condition is a scalar assignment .. from a <>, readline, glob, readdir, or each operation.

    The implicit defined is not added for normal scalar assignments.