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

NAME

Perl::Critic::Policy::Plicease::ProhibitUnicodeDigitInRegexp - Prohibit non-ASCII \d in regular expressions

VERSION

version 0.01

DESCRIPTION

The character class \d in a regular expression matches all unicode digit character, which might not be what you expect if you are testing if a string can be used as a number in Perl. Instead use either [0-9], or if you are on Perl 5.14 or better you can use the /a modifier.

 /\d/;      # not ok
 /\d/a;     # ok

AFFILIATION

None.

CONFIGURATION

This policy is not configurable except for the standard options.

CAVEATS

This is a policy that should not be applied toward all applications without some thought. This is generally true for all Perl::Critic policies, but especially so for this policy.

In the general the ability to match against unicode digits is a useful ability, and doesn't constitute bad code. Some applications don't ever need to match non-ASCII digit characters, and incorrectly rely on \d to validate as a number.

This policy doesn't take into account using the re pragma.

 use re '/a';

 /\d/;  # (still) not ok

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2019 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.