use Encode qw/encode_utf8 decode_utf8/;
use DBIx::Sunny;
use Data::Dumper;
sub dbh {
my ($self) = @_;
return $self->{dbh} //= DBIx::Sunny->connect('dbi:mysql:db=isuda', 'root', '', {
Callbacks => {
connected => sub {
my $dbh = shift;
$dbh->do(q[SET SESSION sql_mode='TRADITIONAL,NO_AUTO_VALUE_ON_ZERO,ONLY_FULL_GROUP_BY']);
$dbh->do('SET NAMES utf8mb4');
return;
},
},
});
}
my $entries = dbh()->select_all(q[SELECT keyword FROM entry]);
my @keywords = map { $_->{keyword} } @$entries;
my $count_of = {};
for my $k (@keywords) {
$count_of->{$_}++ for split('', $k);
}
for ( sort { $count_of->{$a} <=> $count_of->{$b} } keys $count_of ){
print $_, ':', $count_of->{$_}, "\n";
}
上位3つ
Wide character in print at count.pl line 31.
ン:1055
Wide character in print at count.pl line 31.
年:1162
Wide character in print at count.pl line 31.
ー:1272