in reply to Re: Count number of occurrences of a substr
in thread Count number of occurrences of a substr

Note, $n needs to be a local our $n; instead of my $n; for the second snippet to work properly in a sub.