Scripting >> Perl >> How to count the number of occurrences of a substring in a string

eg. To count the number of pagenums in a html buffer $count=0; while ($html =~ /pagenum/g) { $count++ } print "There are $count pagenums";