I took a 6-month hiatus from Perl::Critic work (a new baby and a new job among the causes). Now thanks largely to a Perl Foundation grant I'm back writing policies. I greatly appreciate the forthcoming grant dollars, but even more important to me is the external pressure to get something done. It's easy to slack on work that lacks an invested client.
Tonight I wrote the first of the twenty policies funded by that grant (all of them inspired by Perl Best Practices). Tonight's was Perl::Critic::Policy::BuiltinFunctions::ProhibitComplexMapping which insists that the block argument to map() has at most one statement.
My work in happening in the Perl::Critic 1.xxx SVN branch. You can track it at http://perlcritic.tigris.org/svn/perlcritic/branches/Perl-Critic-1.xxx. Read more about the Tigris SVN, which I always find a little non-intuitive.
prohibitComplexMappings (Score:1)
"The best solutions to a complex mapping are: 1) write a subroutine that performs the manipulation and call that from map; 2) rewrite the map as a for loop."
I guess the advantage of a for loop over a map is that the array over which you are iterating is upfront.
I always have a problem with the indentation of my multiline maps anyway. How should the brackets around the block line up? How should I line up the final array?
Re: (Score:1)
Note that the "no c
Re: (Score:1)
The thing that gets me is you close your map guts and then cuddle the source into that. It's what's driving the entire loop! I'd think it rates pretty highly in importance and should be visually distinct. How about another line for it?
Re: (Score:1)