What is the fastest way to count the number of times a certain string appears in a bigger one? My best guess would be to replace all instances of that string with nothing, c
my $string = "aaaabbabbba"; my @count = ($string =~ /a/g); print @count . "\n";
or
my $count = ($string =~ s/a/a/g);