Why is my regex so slow?

2008-10-31 Thread Mark Wagner
I've got a script I'm using to search through a list of Wikipedia article titles to find ones that match certain patterns. As-written, if you run it and supply '.*target.*' on standard input, it will process my test file in 125 seconds. Make any of the changes mentioned in the comments, and the t

Re: Why is my regex so slow?

2008-10-31 Thread Li, Jialin
try this: print "Match\n" if($target =~ /^$regex$/*o*); only compile regex only once On Fri, Oct 31, 2008 at 2:54 PM, Mark Wagner <[EMAIL PROTECTED]> wrote: > I've got a script I'm using to search through a list of Wikipedia > article titles to find ones that match certain patterns. > > As-

Re: Why is my regex so slow?

2008-10-31 Thread Li, Jialin
On Fri, Oct 31, 2008 at 2:54 PM, Mark Wagner <[EMAIL PROTECTED]> wrote: > I've got a script I'm using to search through a list of Wikipedia > article titles to find ones that match certain patterns. > > As-written, if you run it and supply '.*target.*' on standard input, > it will process my test

Re: Why is my regex so slow?

2008-10-31 Thread Mark Wagner
I probably should have specified: the program in my first email is a minimal sample that can reproduce the problem. The original program is significantly longer and more complex. On Fri, Oct 31, 2008 at 14:38, Li, Jialin <[EMAIL PROTECTED]> wrote: > > print "Match\n" if($target =~ /^$regex$/o);

Re: Why is my regex so slow?

2008-10-31 Thread John W. Krahn
Mark Wagner wrote: I've got a script I'm using to search through a list of Wikipedia article titles to find ones that match certain patterns. As-written, if you run it and supply '.*target.*' on standard input, it will process my test file in 125 seconds. '.*target.*' is inefficient because th

Re: Why is my regex so slow?

2008-10-31 Thread Jenda Krynicky
From: "Mark Wagner" <[EMAIL PROTECTED]> > I've got a script I'm using to search through a list of Wikipedia > article titles to find ones that match certain patterns. > > As-written, if you run it and supply '.*target.*' on standard input, > it will process my test file in 125 seconds. Make any o

Re: Why is my regex so slow?

2008-11-01 Thread Dr.Ruud
Jenda Krynicky schreef: > The thing is that if you use > > $something =~ /^$regex$/; > > in a loop, Perl has to copile the regular expression for each > iteration. Because it can't know whether the $regex variable > is still the same or not. (assuming C) I wouldn't directly know how to test it,