in reply to How to count substitutions on an array

Two remarks:

Use List::Util qw( sum ); $count = sum map s/$foo/$bar/g, @array;
(But use sum0 if @array can be empty and undef won't do.)