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


in reply to Pimp My RegEx

I would have said the same thing that dragonchild pointed out, i.e. that since you are matching the beginning of a line, you can apply your regexp line by line.

However, I'll tell you something more that will save you 30 to 50% of execution time:

Remove "use English;" and change $INPUT_RECORD_SEPARATOR into $/. This will avoid the malicious influence of the so called evil variables ($`, $&, $').

I have actually benchmarked your script with a few hundred lines of logs, and this change saves about 40% of execution time on my laptop.