5 print grep("$foo", @list);
6 print ( grep "$foo", @list );
7 @list = ( grep "$foo", @list );
8 $aref = [ grep "$foo", @list ];
9 $href = { grep "$foo", @list };
11 #-----------------------------------------------------------------------------
13 ## name Counting is allowed
17 $count = grep {m/./xms} @list
19 #-----------------------------------------------------------------------------
21 ## name Non-boolean in conditional
25 if (0 == grep {m/./xms} @list) {}
27 #-----------------------------------------------------------------------------
29 ## name For loop is not conditional
33 for( grep { foo($_) } @list ) {}
34 foreach( grep { foo($_) } @list ) {}
36 #-----------------------------------------------------------------------------
38 ## name Control structures
42 if( grep { foo($_) } @list ) {}
43 unless( grep { foo($_) } @list ) {}
44 while( grep { foo($_) } @list ) {}
45 until( grep { foo($_) } @list ) {}
47 #-----------------------------------------------------------------------------
49 ## name Postfix control structures
53 foo() if grep { bar($_) } @list;
54 foo() unless grep { bar($_) } @list;
55 foo() while grep { bar($_) } @list;
56 foo() until grep { bar($_) } @list;
58 #-----------------------------------------------------------------------------
60 ## name Complex booleans
64 if( 1 && grep { foo($_) } @list ) {}
66 #-----------------------------------------------------------------------------
68 ## name Complex booleans
70 ## TODO need to detect assignment
73 $bar = grep({foo()} @list) && 1;
75 #-----------------------------------------------------------------------------
77 ## name Complex booleans
81 1 && grep({foo()} @list) == 0;
83 #-----------------------------------------------------------------------------
85 ## name Complex booleans
89 1 && grep({foo()} @list) && 0;
91 #-----------------------------------------------------------------------------
93 ## name Complex booleans
95 ## TODO detect end of statement
98 1 && grep({foo()} @list);
100 #-----------------------------------------------------------------------------
102 ## name Complex booleans
106 (1 && grep({foo()} @list))
108 #-----------------------------------------------------------------------------
110 ## name code coverage...
116 #-----------------------------------------------------------------------------
118 ## name code coverage...
124 #-----------------------------------------------------------------------------
126 ##############################################################################
127 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/t/BuiltinFunctions/ProhibitBooleanGrep.run $
128 # $Date: 2008-03-16 17:40:45 -0500 (Sun, 16 Mar 2008) $
129 # $Author: clonezone $
131 ##############################################################################
135 # cperl-indent-level: 4
137 # indent-tabs-mode: nil
138 # c-indentation-style: bsd
140 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :