in reply to truth in while condition
Truthiness is also discussed in Truth and Falsehood in perlsyn. As has been pointed out by others, you were testing "0\n" in the while-loop conditional and not the truly false string "0".
Update: At last, I see the point first made by LanX here: even if <STDIN> managed to return a plain, nominally false "0" character, the loop would still execute because "0" is defined and the special-case while-loop is conditional upon defined-ness! Thanks to BillKSmith (here) and LanX (here) for helping the scales to fall from my eyes.
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: truth in while condition
by LanX (Saint) on Sep 30, 2018 at 21:55 UTC | |
|
Re^2: truth in while condition
by BillKSmith (Monsignor) on Sep 30, 2018 at 21:25 UTC |