in reply to Re: truth in while condition
in thread truth in while condition

Thanks for your reply! Sounds reasonable but what do you think about comment by LanX? It seems they are technically different.

Replies are listed 'Best First'.
Re^3: truth in while condition
by LanX (Saint) on Sep 30, 2018 at 12:10 UTC
    Both are right, but it's a bit tricky to construct a while-condition doing a readline and exiting at false.

    I'd rather use an explicit last with condition inside the body.

    use strict; use warnings; use feature 'say'; while ( $_= <DATA>, chomp, $_) { say; } __DATA__ 3 1 0 2
    -->
    3 1

    (NB: Iterators don't necessarily loop over lines where they need to chomp, <update see here>)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      Get it! Again thanks to the help of both of you~