while () { $count += () = m/foo/g } print $count;