perl -lne '$c++ while /SEARCH_STRING/g; END { print $c; }'
For example, to count the number of times ABCD appears in mysqldump output:
mysqldump my_db | perl -lne '$c++ while /ABCD/g; END { print $c; }'
Modified version of snippet found in http://www.wellho.net/forum/Perl-Programming/Issue-with-Grep.html