in reply to parser for evaluating arbitrarily complex boolean function in a string

The simplest approach would be to use the Math::BooleanEval module to evaluate your expressions to generate the truth table. The operators are a little different between your setup files and the module, but it is a matter of single character substitutions. From the synopsis:
use Math::BooleanEval; my $bool = Math::BooleanEval->new('yes|no'); # evaluate each defined item in the expression to 1 or 0 foreach my $item (@{$bool->{'arr'}}){ next unless defined $item; $item = ($item =~ m/^no|off|false|null$/i) ? 0 : 1; } # evaluate the expression print $bool->eval();

-Mark

  • Comment on Re: parser for evaluating arbitrarily complex boolean function in a string
  • Download Code