Perl::Critic::Policy::RegularExpressions::RequireDotMatchAnything(3pm)

Perl::Critic::Policy::RegularExpressions::RequireDotMatchAnything3pm

Always use the "/s" modifier with regular expressions.

Affiliation

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

Overview

When asked what "." in a regular expression means, most people will say that it matches any character, which isn't true. It's actually shorthand for "[^\n]". Using the "s" modifier makes "." act like people expect it to.

    my $match = m< foo.bar >xm;  # not ok
    my $match = m< foo.bar >xms; # ok

Configuration

This Policy is not configurable except for the standard options.

Notes

Be cautious about slapping modifier flags onto existing regular expressions, as they can drastically alter their meaning. See <http://www.perlmonks.org/?node_id=484238> for an interesting discussion on the effects of blindly modifying regular expression flags.

Releases

9 releases since Debian 6.0 (Squeeze); the text changed 8 times.

  1. 6.0
  2. 7
  3. 8
  4. 9
  5. 10
  6. 11
  7. 12
  8. 13
  9. Arch

Author

Jeffrey Ryan Thalhammer <[email protected]>

From perl-perl-critic 1.156-3 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.