in reply to Re: Truth and Falsehood
in thread Truth and Falsehood

Logically, operators like grep, map, m//, and s/// all return false by returning an empty list, at least in a simple description.

Replies are listed 'Best First'.
Re^3: Truth and Falsehood
by ikegami (Patriarch) on Aug 30, 2019 at 16:31 UTC

    That makes no sense. An empty list isn't false. Or true. It's not a scalar, so those concepts don't apply to it. You can't evaluate whether an empty list is true or false. You can only evaluate if a scalar is true or false.

    As such, if you're trying to get a true or false value from those operators, you would be evaluating them in scalar context, and the following is what the listed operators actually return in scalar context:

    • grep returns the count of matching elements.
    • map returns the count of elements it would return.
    • m// and s/// return success or not.