in reply to Evaluate arbitrary boolean expressions

I can then combine the results from multiple calls to the aforementioned sub to create a more complex boolean expression such as (T && F) || (F && F) etc.

If your sub is called foo() then it's simply

my $bool = (foo() && !foo()) || (!foo() && !foo());

Replies are listed 'Best First'.
Re^2: Evaluate arbitrary boolean expressions
by gauss76 (Scribe) on Mar 13, 2018 at 10:57 UTC

    Yes, sure, but my question is how can I evaluate your variable $bool to true or false?

      gauss76:

      if ($bool) { print "It's true\n"; } else { print "It's false\n"; }

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        OK, that's great but how can I contruct the variable $bool on the fly?

        In general I will have a function that will return values 0 and 1. I can then combine these with operators || and &&. However if I write all this to a string variable $bool the test does not work properly!