$ perl -nle '$count++ while /XY[0-9]+/g; END {print $count}' inputfile
(not what your code does, but what you ask for in the subject line)
In reply to Re: count the number of occurrences of a pattern in a file
by almut
in thread count the number of occurrences of a pattern in a file
by umasuresh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |