my $count = ($string =~ s/(foo)/$1/g); will also do the trick. Benchmarking is left as an exercise for the discerning acolyte.
The match operator (/foo/) only returns a boolean to indicate that it did or did not match. Our friend Mr. Substitution gives us more data.
tr/// is probably much faster for simple substrings, not regex's.