The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


Perl::Critic::Policy::Bangs::ProhibitUselessRegexModifiers - Adding modifiers to a regular expression made up entirely of a variable created with qr() is usually not doing what you expect.


This Policy is part of the Perl::Critic::Bangs distribution.


In older versions of perl, the modifiers on regular expressions where incorrectly applied. This was fixed in 5.10, but no warnings were emitted to warn the user that they were probably not getting the effects they are looking for.


    my $regex = qr(abc)m;
    if ( $string =~ /$regex/ ) {};

Not what you want:

    my $regex = qr(abc);
    if ( $string =~ /$regex/m ) {}; ## this triggers a violation of this policy.

See the thread that starts at: for a description of how this problem can bite the users.

And see: for a description of the bug and subsequent fix.


This Policy is not configurable except for the standard options.


Andrew Moore <>


Adapted from policies by Jeffrey Ryan Thalhammer <thaljef at>, Thanks to Andy Lester, "<andy at>" for pointing out this common problem.


Copyright (c) 2007-2013 Andy Lester <> and Andrew Moore <>

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.