Is there a CPAN module that can read a string like this:
"[[<asdf>, <foo>], (abc, def, ghi), ({'jkl'})]"
...and parse it into some sort of tree structure that's easy to walk and pretty-print?
I think that you could build on top of Text::Balanced, which will do a lot of the heavy lifting for you. You'll still need to build a tree structure, though.
Perl 5.10's regular expressions can handle balanced structures like that. See the (?PARNO) (?-PARNO) (?+PARNO) (?R) (?0)
section in perlre.
Perl 6 is going to have built-in facilities to help support this. In the interim, Text::Balanced (as mentioned by Dave Rolsky) is probably the module of choice. Note that it, too, was written by Damian Conway (as commended by Bill Karwin).
Damian Conway's Parse::RecDescent
I haven't used this, but it's a good bet that a Perl module written by Damian Conway is worth using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With