in reply to RE: Count String Occurrences
in thread Count String Occurrences

I'd suggest using:
$pattern = "whatever"; $mode = "(?"; $mode .= "i" if $case_insensitive; $mode .= "s" if $dot_matches_all; $mode .= "m" if $multiline_match; $mode .= "x" if $allow_comments; $mode .= ")"; $count++ while $string =~ /$mode$pattern/o;
Voila.