in reply to Search and Replace

I think we should benefit from Perl 5.6's (??{ ... }) regex expression.
$REx = qr{ \( (?: (?> [^()]+) | (??{ $REx }) )* \) }x; $str =~ s/($REx)/(my $a = $1) =~ tr!;!,!; $a/eg;
This makes it work for nested parens, too, like "hi; there; (fools; (all))"