in reply to counting matches in a line

Yet another question where there are many ways to do it. Here's just one:
my $count; while (<DATA>) { s/(this)/$count++;$1/ge; # non-destructive version } print "number of this = $count\n";