$_ = "blah,blah(blah,blah(blah,blah(blah))),blah";
#$_="blah1,blah2(blah3,blah4(blah5,blah6(blah7))),blah8";
($re=$_)=~s/((\()|(\))|.)/$2\Q$1\E$3/gs;
@$ = (eval{/$re/});
die $@ if $@=~/unmatched/;
$re = join'|',map{quotemeta}@$;
print join"\n",/((?:$re|[^,])+)/g;
In reply to Re: Balancing Parens
by Anonymous Monk
in thread Balancing Parens
by swiftone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |