in reply to Need a regex to match C-style function arg list

Should you wish to take the Parse::RecDescent leap, here is some code you can play around with. The first major limitation i see with this code is that it only grabs the first two args from a function. That means if you have some functions that have more than two args, those functions first two args will be processed too. There may be more limitations that i did not think of during my limited testing of this code, but hey ... it's a start. ;)
use strict; use warnings; use Parse::RecDescent; use vars qw( %item @item $return @pair @store ); my $data = do {local $/;<DATA>}; my $parser = Parse::RecDescent->new($data); my @code = ( q/concat(int2string(counter, 1),result)/, q/concat("hello","world")/, q/concat(foo,bar)/, ); $parser->startrule($_) for @code; for (0..$#code) { print "$code[$_]\n"; print "\targ 1 => ", $store[$_][0], "\n"; print "\targ 2 => ", $store[$_][1], "\n"; } __DATA__ startrule: function function: label open_p arg comma arg close_p arg: nested_function | quoted_literal | literal nested_function: label open_p arg comma arg close_p { push @main::pair, join('', @item[1..$#item]); pop @main::store; if (@main::pair == 2) { push @main::store,[@main::pair]; @main::pair = (); } $return = join('', @item[1..$#item]); print STDERR "nested function: $return\n"; } quoted_literal: quote /[^"]+/ quote { push @main::pair, $item[2]; if (@main::pair == 2) { push @main::store,[@main::pair]; @main::pair = (); } print STDERR "quoted literal: $item[2]\n"; $return = $item[2]; } literal: /\w+/i { push @main::pair, $item[1]; if (@main::pair == 2) { push @main::store,[@main::pair]; @main::pair = (); } print STDERR "literal: $item[1]\n"; $return = $item[1]; } label: /[a-zA-Z]\w*/ open_p: /\(/ close_p: /\)/ comma: /,/ quote: /"/

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)