http://qs321.pair.com?node_id=244329

spurperl has asked for the wisdom of the Perl Monks concerning the following question:

Friend monks,

We have a certain internal language (a programming language, or more accurately a Hardware Description Language, like Verilog). There are full-fledged parsers for it (C + Lex + Yacc), but I have to do some simple preprocessing and wonder what is the easiest way to go...

Suppose I have some keyword, say "env", which is followed by a body within braces:
env { ... ... }

I want to rip the contents out (from the braces) into some string. Needless to say that there may be other "bodies", delimited by braces nested inside to an arbitrary level, so regexes aren't much of a help (a regex assuming just one level of nesting already looks very scary).

Thus my question: what is the easiest way to handle it ? Use some Parser module from CPAN ? I don't need, and don't want to define the full grammar of this language - I just want what's inside the braces.

TIA