I had to look for what .zsh meant. I guess this is a Mac/Apple thing.
Searching for a count of matching pattern lines, normally uses grep, there is an option to print the number of lines matched. Perl is not required. However Perl can be used for that without requiring a shell program or grep. Why not use command line grep for "count of lines matching a pattern"?