my $count = eval "\$str =~ tr/$char//" or die $@ if $@;