in reply to Re^3: sequential substitutions
in thread sequential substitutions
Can you trust the source of the XML to never change (whitspace, attributes, CDATA, namespaces, comments, etc.), and can you trust the program that's doing the sanitization to never change its output either? What's wrong with installing modules, especially such helpful ones?
Yes, I can. The program whose output I am using is only capable of writing about a dozen specific tags, and there will never be any attributes CDATA, namespaces, or such.
For what I want to do in this specific case, it is just far easier (and more understandable for me) to simply use:
$fragment =~ s/<foo>\d+<\/foo>/'<foo>' . $i++ . '<\/foo>'/eg;
I don't need anything more complicated to accomplish this. While I already learned something regarding this, there is no shortage of things I don't know about perl (even having used it for years for quick tasks, I would still classify myself as a novice). Given the increasing popularity of XML, I am certain there will plenty of opportunities for me to learn more advanced techniques in the future, including specialized modules. :)
Searching for "html tidy" on Google and CPAN shows lots of different options (I haven't used any of them, so I can't give you recommendations). Plus, I wonder why you're asking about such a program, if you said above your XML is already sanitized?
As I noted, that was a "side question" (meaning it has absolutely nothing to do with what I was asking about sequential substitutions). It is for something completely different, and you seem to know quite a bit about the subject, so I just thought it would be a good time to ask that question. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: sequential substitutions
by haukex (Archbishop) on Aug 03, 2018 at 13:07 UTC |