Perl::Critic::Policy::RegularExpressions::RequireDotMatchAnything - Always use the C modifier with regular expressions.


Perl-Critic documentation  | view source Contained in the Perl-Critic distribution.

Index


NAME

Top

Perl::Critic::Policy::RegularExpressions::RequireDotMatchAnything - Always use the /s modifier with regular expressions.

AFFILIATION

Top

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

DESCRIPTION

Top

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

Top

This Policy is not configurable except for the standard options.

NOTES

Top

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.

AUTHOR

Top

Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>

COPYRIGHT

Top


Perl-Critic documentation  | view source Contained in the Perl-Critic distribution.