Guest_imported
New member
- Jan 1, 1970
- 0
Hi, everyone<br>I want to count the number of occurrences my pattern matches in a given string without using s///. I don't need to substitute or translate. I just need to count the matches.<br><br>For example:<br><br>$someStr = "hihihi";<br>$someStr =~ /hi/; # evaluates to true not 3<br>$someStr =~ s/hi/hi/g; # evaluates to 3 but unnecessary substitution and s/// operator will not work with read only values<br><br>any suggestions how to do this efficiently with read only values, too?<br><br>Thanks,<br>Keith