Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep3pm
Don't use "grep" in void contexts.
Affiliation
This Policy is part of the core Perl::Critic distribution.
Overview
"map" and "grep" are intended to be pure functions, not mutators. If you want to iterate with side-effects, then you should use a proper "for" or "foreach" loop.
grep{ print frobulate($_) } @list; #not okprint map{ frobulate($_) } @list; #okgrep{ $_ = lc $_ } @list; #not okfor( @list ){ $_ = lc $_ }; #okmap{ push @frobbed, frobulate($_) } @list; #not ok@frobbed = map { frobulate($_) } @list; #ok
Configuration
This Policy is not configurable except for the standard options.
Releases
10 releases since Debian 5.0 (Lenny); the text changed 9 times.