in reply to Counting how many times a character is in a string.

as mention several times already, tr is probably best for single characters. Another solution, which is scalable to multi-charater delimiters, is to use split:
use strict; use warnings; my $str='abc%def%.%'; printf "pcount: %d\n", split(/%/, $str.' ')-1;
(the .' ' is for the case of a trailing %, where split throws out the last empty element)