in reply to search for matching parentheses

I ran into this problem awhile ago and wrote some code to handle it. It feels like a kludge, but it works:
my @args = ( split/,/, $line ); my $size = $#args; # ugly hack to rejoin args that were incorrectly split (intern +al commas) for ( my $i = 0; $i < $size; $i++ ) { my $depth = 0; $depth++ while $args[$i]=~/[(]/g; $depth-- while $args[$i]=~/[)]/g; if ( $depth ) { splice ( @args, $i, 2, $args[$i].",".$args[$i+ +1] ); $i--; $size--; } }
Basically, it splits the line on commas and then makes sure the number of parenthesis in each splitted item match. If they don't, it splices the next line and recounts. So after you run your string through this code, the args array should be populated with the separated smaller strings.

Once you have the big string correctly split into the smaller strings, the regex is as simple as this:

$args[$i] =~ (\w+)\(([^)]*)\) my $param = $1; my $stuffinsideparens = $2;
If you really wanted to, you could just append this code at the bottom of the for loop.