Big regexps are hard to read,
perhaps even the hardest part of Perl.
A good practice to write digestible chunks of regexp and put them together.
This policy flags any regexp that is longer than N characters,
where N is a configurable value that defaults to 60.
If the regexp uses the x flag,
then the length is computed after parsing out any comments or whitespace.

Unfortunately the use of descriptive (and therefore longish) variable names can cause regexps to be in violation of this policy,
so interpolated variables are counted as 4 characters no matter how long their names actually are.

If you read the code from bottom to top, it is quite readable. And, you can even see the one violation of RFC822 that Tatsuhiko Miyagawa deliberately put into Email::Valid::Loose to allow periods. Look for the |\. in the upper regexp to see that same deviation.

One could certainly argue that the top regexp could be re-written more legibly with m//x and comments. But the bottom version is self-documenting and, for example, doesn't repeat \x80-\xff 18 times. Furthermore, it's much easier to compare the second version against the source BNF grammar in RFC 822 to judge whether the implementation is sound even before running tests.

This policy allows regexps up to N characters long, where N defaults to 60. You can override this to set it to a different number with the max_characters setting. To do this, put entries in a .perlcriticrc file like this: