Perl::...imiters(3pm)

okay so bestie πŸ’… this is the Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters page β€” the header does its usual Perl::...imiters(3pm) thing, it's from the User Contributed Perl Documentation collection, and we're about to get into it. It's giving "regex delimiters but make it legible" energy, and honestly? iconic.

✨ NAME ✨

Use only // or {} to delimit regexps. That's it. That's the assignment, periodt. πŸŽ€

🫢 AFFILIATION 🫢

This Policy is part of the core Perl::Critic distribution. It's not some random side quest β€” it's core, bestie. πŸ’–

πŸ’… DESCRIPTION πŸ’…

Perl lets you delimit regular expressions with almost any character, but most choices are illegible. Compare these equivalent expressions, bestie:

s/foo/bar/;   # good
s{foo}{bar};  # good
s#foo#bar#;   # bad
s;foo;bar;;   # worse
s|\|\||\||;   # eye-gouging bad

The // and {} ones? Cute, clean, slay. The # one is bad, the ; one is worse, and that last one is literally eye-gouging bad 😭. The original says "eye-gouging bad" and I'm not arguing with it.

πŸŽ€ CONFIGURATION πŸŽ€

There is one option for this policy, allow_all_brackets.

  • allow_all_brackets β€” if this is true, then, in addition to allowing // and {}, the other matched pairs of (), [], and <> are allowed.

In other words: // and {} are the good ones; flip allow_all_brackets to true and the other matched pairs (), [], and <> are allowed too. πŸ¦‹

🌟 CREDITS 🌟

Initial development of this policy was supported by a grant from the Perl Foundation. Love that for this policy, honestly 🫢.

πŸ‘‘ AUTHOR πŸ‘‘

Chris Dolan <cdolan@cpan.org> β€” the author, the icon, the main character of this section. πŸ‘‘

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

That's the whole page, bestie. mwah πŸ’‹ β€” source/version: perl v5.42.0, date: 2024-10-23. slay.

πŸ“¦ where this page comes from