CmdrTaco has asked for the wisdom of the Perl Monks concerning the following question:
Whats a clean way to count the occurances of a substring
withing a string? I've been using $x++ while /foo/g; to count the
occurances of 'foo' within $_, but it really seems like $x=/foo/g;
ought to (in scaler context) return a count, but for some reason it
always returns either undef or 1 (eg, a boolean).
Back to
Seekers of Perl Wisdom