It could be a job for Parse::RecDescent. But Parse::RecDescent is well, a recursive descent parser. Which means, it doesn't take short cuts. It's very general. It will explore and explore and explore, and backtrack and explore and explore and do some more backtracking, and then start all over again before deciding "nope, no way, absolutely no way this is going to match". While powerful, it's not efficient.
Your syntax looks simple enough that you can parse it with a limited look-ahead parser, which doesn't backtrack more than the number of tokens it looks ahead.
Usually, much faster. But you may have to do a lot more work to have a parser. So, you have to make a trade off. How much programming time are you willing to spend to speed up the runtime. Of course, if the files you're going to parse are small, or if the grammar is simple, or if the data is such that it never backtracks anyway, Parse::RecDescent maybe fast enough anyway.
There's no easy answer to this question.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.