Keep It Simple, Stupid | |
PerlMonks |
Search & Replace Parsing?by Guildenstern (Deacon) |
on Apr 18, 2001 at 22:04 UTC ( [id://73607]=perlquestion: print w/replies, xml ) | Need Help?? |
Guildenstern has asked for the wisdom of the Perl Monks concerning the following question:
I'm currently working on a small personal project that involves converting HTML and plain text to a semi-proprietary markup language. I have several tables of HTML tags that must be converted, and am trying to devise the most efficient way to perform this task without completely reinventing the wheel. So far, I've looked at Parse::RecDescent and Template, but these don't seem to have the "search & replace" functionality that I need. RecDescent has no problems finding specific tags, but I have not been able to find out how to perform a replacement that affects the text passed in to the parser. It's simple enough to write a grammar rule that matches a <html> tag, but I don't know what to do in the action portion of the rule. If I act on @item, the changes aren't reflected in the original text. Template Toolkit also seems a bit limited for what I'm doing. It obviously has the search and replace functionality, but I don't seem to be able to find any way to specifiy specific search and replace pairs. I know that I can throw all of my search and replace pairs into a great big hash and loop, but this seems to be a far cry from the best answer. Is there something in Parse::RecDescent or Template Toolkit that I'm missing? Is there some other module available that will let me do search and replace in the manner that I need? I did quite a bit of research on CPAN, but it's entirely possible that I missed something. And before anybody makes the statement, no there are no convertors or modules available for the markup language I'm using. Guildenstern Negaterd character class uber alles!
Back to
Seekers of Perl Wisdom
|
|