P
Pete Sammet
Sorry for this newbie question:
Is there a function in Perl for counting the number of e.g. "a" in a String ?
For example:
$num = countchars("abbbabbbaba", 'a');
should yield 4. Unfortunately the function "countchars" does not exist.
is there another one-liner function ?
Another realted but more advanced question:
Is there a counter function for counting INDEPENDENT "a" in a String?
In this case concatenated "a" should be counted as 1. e.g.
$num = countcharschains("aammmammaaaaam", 'a');
Should yield 3
Pete
Is there a function in Perl for counting the number of e.g. "a" in a String ?
For example:
$num = countchars("abbbabbbaba", 'a');
should yield 4. Unfortunately the function "countchars" does not exist.
is there another one-liner function ?
Another realted but more advanced question:
Is there a counter function for counting INDEPENDENT "a" in a String?
In this case concatenated "a" should be counted as 1. e.g.
$num = countcharschains("aammmammaaaaam", 'a');
Should yield 3
Pete