Parsing function arguments

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Apologies in advance if this is too newbie-ish. Couldn't find the
answer via googling or looking at various FAQ's.

Given a C function call in a string, how do I parse out the individual


"... func ((a+b)/c,d,e,f+(g+(h,i))) ..."

I need to get an array that is


I know I can use extract_bracketed to get the outermost set of braces,
but how to I split out the arguments therein? (Note I can't just use
split on the comma since one of the comma's is embedded in a bracket

Glen Low, Pixelglow Software

Re: Parsing function arguments wrote:
Quoted text here. Click to load it

Try taking a look at
perldoc -q delimited
"How can I split a [character] delimited string except when inside
[character]? (Comma-separated files)"

That generally deals with the case in which a CSV line has commas
embedded in quoted fields, but you should be able to modify the
solution (or use one of the two recommended modules) for your problem
as well...

Paul Lalli

Site Timeline