A more normal way to use reduce would be to use the + operator in there, not +=. Using += could give the impression that the variable $a can be usefully modified within the block.
say reduce { $a + count_zeros($cgs,$b) } 0, <DATA>;
In reply to Re^2: Summing Variables in foreach loop
by tobyink
in thread Summing Variables in foreach loop
by ccelt09
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |