| [reply] |
| [reply] |
My response is directed toward your subject line for this post, as the content of the post doesn't ask a question, or even put forth a need.
You said you need to write a regular expression in Perl for XML code. All I can contribute to such a vague statement of design specification is that, having used XML to some extent, I haven't ever had to write a regular expression to parse XML. That's not to say regular expressions aren't used in the course of XML parsing with Perl, but they're generally encapsulated in modules that do the heavy lifting for you. The advantage to such modules is that they're well thought out, refined, heavily tested, and have passed through the hot forge of large user-bases.
You can write your own XML parser if you wish. But when General Motors builds a car, they don't boil the rubber out of trees from the Amazon to make their tires. In fact, they don't even make tires; they buy them from a supplier who has more experience in that specific aspect of manufacturing. GM could, if they wanted to, manufacture their own tires. But they've realized that it's beneficial to let an expert handle that detail for them.
I recommend you have a look at a few of the following CPAN modules: XML::Twig, XML::Simple, XML::LibXML::Parser... there are many others well tested and highly thought of. But these cover a broad array of needs. Yes, even you can use CPAN. If you're on ActiveState Perl, look at PPM to see what it has to offer for XML modules. If you're on a kinder flavor of Perl (Strawberry, or most Linux environments), it's as easy as typing "cpan install module::name."
| [reply] |
| [reply] [d/l] |