in reply to Re: Parsing parenthetical arguments recursively
in thread Parsing parenthetical arguments recursively

So you don't want to test and reject unbalanced parens? for instance:
$string = "((2 > 1) | ('word' eq 'toy')))";
If you did you may want to use one of the balanced modules to verify balance of the parens.

-Waswas

Replies are listed 'Best First'.
Re: Re: Re: Parsing parenthetical arguments recursively
by Moe (Novice) on Aug 16, 2003 at 16:19 UTC
    The same code(now working) is being used to accomplish that, actually. I use the same regexp when the user supplies the expression to verify its validity, without doing any evaluation on it:

    while ($tmp =~ /\(((?:[^()])*?)\)/) { my $assert = $1; $assert =~ s/\|/\\\|/g; $tmp =~ s/\($assert\)/$1/; } ($tmp =~ /\(|\)/) ? print "Don't match.\n" : print "Match.\n";

    Just as a purely hypothetical example. Though, I will definitely look into those modules, as I'd not heard of them before. Thank you for the link.

    ~Moe~