$string="abc%def%.%"; $count = ($string =~ tr/%//); print "There are $count %s in the string";