note
philipbailey
<p>My eye is drawn to this:</p>
<c> $line =~ /\[(.+?)\] .* \[(.+?)\] .* \[[^]]+\] \s+ (.*) /x or next ;</c>
<p>It seems to me that the repeated <c>.*</c> is likely to result in a lot of backtracking during the match of the regex. I suggest you try replacing the first two <c>.*</c> expressions with something like <c>[^\[]+</c> and add a <c>$</c> anchor at the end. That would change that line to:</p>
<c> $line =~ /\[(.+?)\] [^\[]+ \[(.+?)\] [^\[]+ \[[^]]+\] \s+ (.*)$ /x or next ;</c>
<p>There may be something more elegant you could do (and somebody will chip in) but I bet that will result in a speed improvement.</p>
<p>Mind you, the O n^2 algorithm won't help.</p>
1098132
1098132