in reply to Re: Which packet sniffing module should I choose?
in thread Which packet sniffing module should I choose?

I went through much the same exercise a year or so ago, and also picked XML::Twig. But I spent a lot of time on the research, there was no obvious place to go to find out even what was most popular, let alone what was the 'best'.

Why do you say you 'obviously' picked XML::Twig?

More recently, I had to do some XML stuff and this time picked XML::Smart, which suited the particular task better. But again I had to do my own research.

  • Comment on Re^2: Which packet sniffing module should I choose?

Replies are listed 'Best First'.
Re^3: Which packet sniffing module should I choose?
by Tanktalus (Canon) on Oct 02, 2006 at 13:37 UTC

    If you read my basis for selection, you'll notice that one of the basis was having a single solution be MTOWTDI. XML::Twig is the only module that I know of that has more than one approach to XML. You can deal with each twig during processing (before or after or both) - great for transformations. Or you can load the whole thing into memory and use xpath-like expressions to find your data. I usually do the latter, though I've used the former from time to time.

    It appears, from a very cursory glance, that XML::Smart is not necessarily a lot different from XML::Simple. XML::Smart may be able to handle more cases, and seems to have more syntactical sugar, but it, too, seems to take XML and simplify it down to common perl structures. Which means it can be great for things like serialising data for your own use. But may not be so great for fulfilling certain DTDs.

    XML::Twig seems to have two very important features that make it the only choice for me. In order of priority for me and my use (which may not apply to you in your situation, that's why there really are many ways to do things), they are: a) XML::Twig keeps everything in its original context. This can be important in fulfilling those DTDs. What this means is that if I have two pieces of XML such as:

    <foo> <bar>blah</bar> </foo>
    and
    <foo bar="blah" />
    that XML::Twig handles these differently. However, XML::Simple does not. (You can choose the output of XML::Simple to be one or the other, but I'm not sure how to get it to do both - and to do that depending on the original input.) I suspect that XML::Smart does not do this either.

    And, b) of the modules that do (a), it does so in the simplest, most perlish way. The modules that do (a) are generally the low-level ones that wrap around the DOM or whatever parsing mechanism they use at a very direct level. By no means is XML::Twig "simple" - but of this group, it is easily the winner.

    Does that mean it's always the best module to use? Not necessarily. But it has been for me.