Most of the default Perl::Critic policies come from TheDamian's Perl Best Practices. The rationale for the policies can be found in perlcritic's verbose output, the POD (in this case, Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap), and of course the book (page 169).
$ perlcritic 11119158.pl
Expression form of "map" at line 8, column 12. See page 169 of PBP.
+(Severity: 4)
$ perlcritic --verbose 11 11119158.pl
Expression form of "map" at line 8, near 'my @list = map "$_ beads", @
+colors, @grey_scale;'.
BuiltinFunctions::RequireBlockMap (Severity: 4)
The expression forms of `grep' and `map' are awkward and hard to r
+ead.
Use the block forms instead.
@matches = grep /pattern/, @list; #not ok
@matches = grep { /pattern/ } @list; #ok
@mapped = map transform($_), @list; #not ok
@mapped = map { transform($_) } @list; #ok
Although Perl::Critic policies usually have a very good reason, some of them can be seen as stylistic choices and one can disagree with PBP if one knows what one is doing. The severify of policies can be changed via the config file, e.g.:
$ cat ~/.perlcriticrc
severity = 3
[BuiltinFunctions::RequireBlockMap]
severity = 2
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|