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


in reply to Re: Bench this BBcode Part 2
in thread Bench this BBcode Part 2

Perhaps you should compile this once with the qr operator instead of every time you use it?
No, he shouldn't. That *slows* down the program (although probably not measurable). I see $long_regex only be used twice, and in both cases it's interpolated. There's no point in making the compile-stringify round trip, if all you're needing is the string form. (On top of that, after the roundtrip, the resulting string is larger).

Using qr to avoid additional compilation only makes sense if you don't interpolate, and use it in different places.