in reply to doubt on regex

The issue is how does a machine determine which parenthesis shouldn't be there?
Consider the following code and adapt
my $string="one two one two"; my @ones=$string=~m/\bone\b/g; my @twos=$string=~m/\btwo\b/g; print scalar(@ones) ,"\t\"ones\"\n",scalar (@twos),"\t\"twos\"\n"; print "Equal numbers\n" if (scalar (@ones)== scalar (@twos));'
You can flag that there are unmatched braces on a line, but a human may be needed to determine which is the incorrect brace. Hope this helps

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."