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::ProhibitStringyEval
  • Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap

πŸ’Œ AUTHOR πŸ’Œ

Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> wrote this one. Iconic. πŸ‘‘

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