my $str='abc%def%.%'; my $count = $str =~ tr/%/%/; print "\"$str\" has $count % in it.\n";