in reply to Perl with XML

And as for the comments about using XML::Parser instead of RegExps, the RiskGrades engine handles thousands of XML requests daily, and it required significantly more over-head (especially under mod_perl, which occasionally has had freaky memory retention problems) to use Parser. We did Benchmark both, and straight RegExps came out well ahead. I do agree that Parser should be used for non mission-critical apps, tho.

The point about use strict is valid and has been corrected in the quiz.

As for the "broken" regexp that Tachyon described most eloquently above, it was actually used to translate a bunch of files that had been raped by DreamWeaver. The only valid tags were the <b> and <i> tags (which were all lower case), but I needed to keep track of where the other ones were, so I used "x"s. Not terribly elegant, but made for a good question (that most people get wrong).

Replies are listed 'Best First'.
Re: Re: Perl with XML
by mirod (Canon) on Oct 26, 2001 at 16:31 UTC

    No! Your code does NOT parse XML. It parses a limited subset of XML. It might be OK for the data you handle right now but it means that you cannot change this data. Are the restrictions you put on the XML clearly documented somewhere? Because if you have to receive data from a source that you don't control and if you just tell them "it's XML, here is the DTD/schema" I can tell you that you open the door to tons of problems. People do use entities, comments, processing instructions, namespaces and the likes! And as this regexp based parsing does no validation whatsoever of the incoming XML, how do you know you can trust it?

    In short you are using an internal format, that looks a little bit like XML but that is not XML. This is fine except when you call it XML. I understand that the quizz is for applicants to your company only, so it's not like you were advocating your method in a public forum, but I still want to warn people (and you!) against thinking that XML is simple to process using regexps.

    BTW if you don't want to use XML::Parser you can also use XML::Parser::Lite, which is regexp based, or libXML, or soon the new XML::SAX::PurePerl or you could use a real (and fast) XML processor to generate a version of the data that you know you can handle (expanding entities, discarding comments...)

Re: Re: Perl with XML
by buckaduck (Chaplain) on Nov 01, 2001 at 01:19 UTC
    The point about use strict is valid and has been corrected in the quiz.

    I hope that RiskGrades counts this in my favor if I should decide to apply! (And I just might do that; I'll be looking for a new job next year when my worksite closes...)

    buckaduck