Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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

by Erez (Priest)
on Aug 09, 2012 at 07:26 UTC ( #986428=note: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://986428]
[oiskuu]: ... getlogin refers to tty owner; if you close STDIN, then getlogin returns undef. I get undef in my shell (running under X)
[tye]: Then there is a more persistent big of data similar to getlogin(). I don't believe even daemonizing drops it. So you can tell services that were started at boot time from those started by a person.
[tye]: I'll have to look into that later. getlogin() suites my current needs.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2017-06-23 19:17 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (554 votes). Check out past polls.