use strict; use warnings; use utf8; use DBIx::Custom; my $word ='δΈ»'; my $word_length = length $word; my $word_q = quotemeta($word); my $dbi = DBIx::Custom->connect( dsn => "dbi:SQLite:dbname=../db/bible.db", option => {sqlite_unicode => 1} ); for (my $i = 0; $i < 66; $i++) { my $num = sprintf "%02d", $i + 1; my $content = $dbi->select( 'content_no_tag', table => 'book', where => {id => $num} )->value; my $content_length = length $content; $content =~ s/$word//g; my $content_length_no_word = length $content; my $word_count = ($content_length - $content_length_no_word) / $word_length; print "$num:$word_count\n"; } 1;