Sep 14, 2010, 8:57 AM
Post #1 of 2
Hi, the title should say it all
Matching right and left paranthesis in a long string
the code I currently have is:
my @right_p = $tree =~ /(\()/g;
my @left_p = $tree =~ /(\))/g;
print $#right_p == $#left_p ? "YES\n" : "NO\n";
Is there any way of circumventing the use of these two arrays, and truncating this block into one line perhaps?
I have tried comparing both regexs directly but it just compares "1" instead.
Thanks in advance!