Perl::...atching(3pm)

πŸ’… NAME πŸ’…

okay so bestie, welcome to Perl::...atching(3pm) β€” the User Contributed Perl Documentation page for Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching. This policy is literally all about always using the /m modifier with regular expressions. periodt. ✨

πŸ¦‹ AFFILIATION πŸ¦‹

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

✨ DESCRIPTION ✨

So here's the vibe: folks coming from a sed or awk background tend to assume that $ and ^ match the beginning and end of the line, rather than the beginning and end of the string. iykyk. Adding the /m flag to your regex makes it behave as most people expect it should. it's giving β€œplease stop confusing me” energy. 😭

my $match = m{ ^ $pattern $ }x;  #not ok
my $match = m{ ^ $pattern $ }xm; #ok

πŸŽ€ CONFIGURATION πŸŽ€

This Policy is not configurable except for the standard options. that's it, that's the whole config section. πŸŽ€

🌸 NOTES 🌸

For common regular expressions like e-mail addresses, phone numbers, dates, etc., have a look at the Regexp::Common module. highly recommend, bestie. πŸ“

Also, be cautious about slapping modifier flags onto existing regular expressions, because they can drastically alter their meaning. like, do not just throw flags at a regex and hope for the best, fr fr. See <http://www.perlmonks.org/?node_id=484238> for an interesting discussion on the effects of blindly modifying regular expression flags. πŸ”₯

πŸ‘‘ AUTHOR πŸ‘‘

Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> β€” icon. πŸ‘‘

Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.

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. πŸ’œ


cute sign-off: this page is from perl v5.42.0, dated 2024-10-23, and the manual is Perl::...atching(3pm). stay matching those line boundaries, bestie. πŸ’…πŸŒˆ

πŸ“¦ where this page comes from