Perl::...ckGrep(3pm)
π NAME π
okay bestie, welcome to the Perl::...ckGrep(3pm) page π
this is all about Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep β the policy that wants you to write grep { /$pattern/ } @list instead of grep /$pattern/, @list. That's it, that's the vibe. β¨
π AFFILIATION π
This Policy is part of the core Perl::Critic distribution. No extra drama. π«Ά
πΈ DESCRIPTION πΈ
So the tea is: the expression forms of grep and map are awkward and hard to read. Use the block forms instead, periodt. π
@matches = grep /pattern/, @list; #not ok
@matches = grep { /pattern/ } @list; #ok
@mapped = map transform($_), @list; #not ok
@mapped = map { transform($_) } @list; #ok
βοΈ CONFIGURATION βοΈ
This Policy is not configurable except for the standard options. That's the whole config chapter, bestie β no secret knobs. π
π SEE ALSO π
Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEvalPerl::Critic::Policy::BuiltinFunctions::RequireBlockMap
π AUTHOR π
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> wrote this one. Iconic. π
π COPYRIGHT π
Copyright (c) 2005-2013 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.
That's the whole legal tea. π
mwah π β signed off from the User Contributed Perl Documentation for perl v5.42.0, dated 2024-10-23. π
π¦ 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