in reply to converting boolean strings into conditions for database queries

You would need to write your own function like this one.

$string = "(+goat -boy) +hair"; @cols = qw(t1.c1 t1.c5 t1.c8); print my_cond($string,@cols); sub my_cond { my ($string,@cols) = @_; my $cond = ''; for my $col (@cols) { $_ = $string; s/(\w+)/'$1'/g; s/\+/and $col=/g; s/-/not $col=/g; $cond .= $_." or\n"; } $cond =~ s/^(\()and /$1/gm; $cond =~ s/ or$//; return $cond; }
  • Comment on Re: converting boolean strings into conditions for database queries
  • Download Code