Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap - Write C instead of C.


Perl-Critic documentation  | view source Contained in the Perl-Critic distribution.

Index


NAME

Top

Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap - Write map { $_ =~ /$pattern/ } @list instead of map /$pattern/, @list.

AFFILIATION

Top

This Policy is part of the core Perl::Critic distribution.

DESCRIPTION

Top

The expression forms of grep and map are awkward and hard to read. 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







CONFIGURATION

Top

This Policy is not configurable except for the standard options.

SEE ALSO

Top

Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval

Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep

AUTHOR

Top

Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>

COPYRIGHT

Top


Perl-Critic documentation  | view source Contained in the Perl-Critic distribution.