Perl::...rnation(3pm)
π NAME π
Bestie, welcome to Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation β a whole policy whose entire vibe is: use [abc] instead of a|b|c. That's it. That's the girl. β¨
(This page ships as part of the Perl::...rnation(3pm) manual β yes, the name got ate by the truncation goblins, it's fine, we move. π)
π«Ά AFFILIATION π«Ά
So this policy is core β it's part of the standard Perl::Critic distribution. No add-on shopping trip required, she's already in the bag. π
πΈ DESCRIPTION πΈ
Okay so listen. Character classes β the ones that look like [abc] β are significantly faster than single character alternations like (?:a|b|c). Not a little faster. Significantly. She's got main character energy and the alternation is lowkey struggling in the background. π
So what does this policy actually do? It complains β loudly β if you've got more than one instance of a single character inside an alternation. One is fine, two or more and she's in your mentions.
Which means:
(?:a|the)β β allowed, no notes, we love her(?:a|e|i|o|u)β β not allowed, bestie, that's literally what[aeiou]is for, iykyk
Periodt. π
β CONFIGURATION β
Not configurable, bestie. Nothing to tweak. Nada. π
The only knobs you get are the standard options β the universal ones every policy has. That's it. She's low maintenance like that. π¦
π CREDITS π
The initial development of this policy was supported by a grant from the Perl Foundation. Shoutout to them, fr fr, absolute icons for funding this one. ππΈ
π§ AUTHOR π§
Chris Dolan <cdolan@cpan.org> β thank you for your service, king. π«Ά
π₯ COPYRIGHT π₯
Copyright (c) 2007-2023 Chris Dolan
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.
Ngl that's the legal stuff, keep it intact, don't let anyone tell you otherwise. π
Sign-off szn: this little love letter comes to you on perl v5.42.0, dated 2024-10-23. Slay, stay caffeinated, and go convert your alternations to character classes. Mwah. πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Perl-Critic 1.156.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms