Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!purdue!bu.edu!nntp-read!jbw From: jbw@bucsf.bu.edu (Joe Wells) Newsgroups: comp.lang.perl Subject: perl slowness with regexp Message-ID: Date: 6 Mar 90 03:11:06 GMT Sender: news@bu.edu.bu.edu Organization: Boston University Computer Science Department Lines: 28 I ran into some interesting perl behavior recently. The following short program will illustrate it: for (1 .. 20) { $_ = 'Y' . ('x' x $_); print "_: $_\n"; m/(.+)*Y/; print "`: $`, 1: $1, &: $&, ': $'\n"; } If you run this program, you will notice that each iteration of the loop takes much longer than the previous iteration. Am I correct in guessing that this is perl's way of telling me don't do that? Or is this kind of regular expression optimizable? For the curious, this is the original regexp from which I distilled the one in the program above: ^\s*(\S+(\s*\S+)*)\s*<.*>$ I was trying to exclude the spaces on the end of what I was looking for. Since then, I've done that afterwards. -- Joe Wells jbw%bucsf.bu.edu@cs.bu.edu ...!harvard!bu-cs!bucsf!jbw