Subject: | Suggested policy: forbid /o regexp flag |
In the old days, you could put the /o flag on a regexp using interpolated
variables to indicate it should be compiled just once. Nowadays the
regexp compilation is memoized by the perl runtime, so if the interpolated
string hasn't changed, there is very little speed penalty. On the other
hand, /o can introduce a bug if the string *has* changed for some reason.
(If you really want to get the interpolated string once and then save it
for future matches, even though variables may have changed, then there are
clearer ways to express this than using the /o flag.)
See <http://article.gmane.org/gmane.comp.lang.perl.perl5.porters/92750>
for background.
Perl::Critic should have a policy at medium severity discouraging the
use of /o on regexps.