How To Count Strings Inside Another In Perl
erics, Posted June 16th, 2021 at 12:19:06pm
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
Leave Your Comment
All fields marked with "*" are required.