my $n = 0; ++$n while $str =~ m/this/g;