perlquestion
manish.rathi
<p>
1) <c>while(<stdin>){print " I saw $_" ;} </c>
</p><p>
# Is thie equivalent to
</p><p>
2) <c>while($_=<stdin>){ print "I saw $_" ;} </c>
</p><p>
If it is so, , how will this code end after printing "I saw whateverentered"
</p><p>
As there is no "defined" used in while loop , so how will while loop end because undefined value in the $_ will not let the loop end.
</p><p>
3) <c>while(defined($_= <stdin>)){print "I saw $_ " ;} </c>
</p><p>
In either of these three codes, output is the same.
</p><p>
While I was going thru book, it is stated for the first code "Read a line of input and see if its true. And if its true, enter the while loop but throw away that line of input." What does this mean ? Does it mean that line of input will be read but not printed ? Why not ? Because by default any input will be assigned to $_.
</p><p>
Pls explain.
</p>
<p><small>20090217 Janitored by [id://5348]: Added formatting, code tags, as per [id://17558]</small></p>