http://www.perlmonks.org?node_id=986428


in reply to Matching simple patterns - is there a faster way?

is regex matching the fastest way to go?

Depends. In Perl it probably is, being a well implemented algorithm. In general it's not, since the regex algorithm isn't as fast as the one you find in Unix grep and similar, but is more robust and allows for a lot of clever and powerful matching.

But that's obviously the wrong question, given that a: this looks like a premature optimization, and b: Perl isn't that fast to begin with, due to a lot of stuff that goes behind the scenes which allows for all the flexibility and DWIMability. A better, I believe, course would be to profile the entire program run, see what are the bottlenecks and then figure how to better iron them out, rather than assuming the regex engine will be your biggest problem, rather than, say, Perl's IO.

Principle of Least Astonishment: Any language that doesn’t occasionally surprise the novice will pay for it by continually surprising the expert

  • Comment on Re: Matching simple patterns - is there a faster way?

Replies are listed 'Best First'.
Re^2: Matching simple patterns - is there a faster way?
by mrguy123 (Hermit) on Aug 09, 2012 at 07:55 UTC
    Hi Erez, you're correct that the bottleneck is not the regex matching (it is the HTML downloading). However, if I can make the regex matching a bit faster it will be helpful
    Also, as I mentioned before, this is I think an interesting question that I would like to hear the Monks opinion on

    BTW, I enjoyed your talk on "The view from under the bridge" in the Israeli Perl Workshop earlier this year