Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: XML parsing vs regex

by Your Mother (Chancellor)
on May 13, 2013 at 22:07 UTC ( #1033368=note: print w/replies, xml ) Need Help??


in reply to Re: XML parsing vs regex
in thread XML parsing vs regex

What makes you say parsing is slower? I would expect XML::LibXML to be faster than manual file handling + regular expressions. While I have no benchmarks, neither have I made any assertions. :P

Replies are listed 'Best First'.
Re^3: XML parsing vs regex
by space_monk (Chaplain) on May 14, 2013 at 05:35 UTC

    Its an assumption, I grant you, but I think I'm on safe ground when I think that building a DOM tree out of a document, followed by an XPath search is very likely to be more time consuming than a single regex pass. ;-)

    I would be curious to see how close various approaches get though, so if anyone is willing to benchmark say LibXML, XML::Twig and regex, I would like to see the results

    If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1033368]
help
Chatterbox?
[Lady_Aleena]: Why does grep(/.*$in.*/, @my_modules) work but grep { $_ =~ /.*$in.*/; $_ } @my_modules not work? What did I do wrong in the second?
[tobyink]: Why are you returning $_ n your grep block? You should return a boolean.
[tobyink]: *in your grep block
[tobyink]: You can use grep { $_ =~ /.*$in.*/; } @my_modules but why not stick to grep(/.*$in.*/, @my_modules)? (The latter is faster.)
[shmem]: Lady_Aleena, in the first example grep evaluates the result from grep and if true, returns $_. In the second, it always returns $_
[shmem]: ..the result from the pattern match

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2017-05-27 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?