Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap - Don't use C in void contexts.


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

Index


NAME

Top

Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap - Don't use map in void contexts.

AFFILIATION

Top

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

DESCRIPTION

Top

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 ok
    print map{ frobulate($_) } @list;            #ok

    grep{ $_ = lc $_ } @list;                    #not ok
    for( @list ){ $_ = lc $_  };                 #ok

    map{ push @frobbed, frobulate($_) } @list;   #not ok
    @frobbed = map { frobulate($_) } @list;      #ok




CONFIGURATION

Top

This Policy is not configurable except for the standard options.

AUTHOR

Top

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

COPYRIGHT

Top


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