$str = '( (1 == 1) and (2 < 1) ) or (2 > 0)'; while ($str =~ s/(\([^()]+\))/$1/ee) { if (not eval($1)) { print "error: $1\n"; last; } }