Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Truth and Falsehood

by jcb (Parson)
on Aug 18, 2019 at 07:13 UTC ( [id://11104638]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11104638]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2025-12-08 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (87 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.