How To Count Strings Inside Another In Perl
erics, June 16th, 2021
1 2 3 4 5 |
my $needle = 'foo'; my $haystack = 'foo foo foo'; my @count = $haystack =~ /$needle/g; my $count = scalar @count; print "$count\n"; |
Should result in 3