# 文字数を数える
my $count = $str =~ tr/^//;


コメント書くぐらいなら
コード自体にコメントと同じ情報量を
埋め込んだほうがいい。

my $count = count_char($str, '^');