Created
August 18, 2011 07:06
-
-
Save vkgtaro/1153565 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| use utf8; | |
| use Encode qw/encode/; | |
| my $judging_katakana_list = { | |
| ア => qr/^[ア-オ]/, | |
| カ => qr/^[カ-コ]/, | |
| サ => qr/^[サ-ソ]/, | |
| タ => qr/^[タ-ト]/, | |
| ナ => qr/^[ナ-ノ]/, | |
| ハ => qr/^[ハ-ホ]/, | |
| マ => qr/^[マ-モ]/, | |
| ヤ => qr/^[ヤ-ヨ]/, | |
| ラ => qr/^[ラ-ロ]/, | |
| ワ => qr/^[ワ-ン]/, | |
| }; | |
| my @katakanas = ( | |
| 'アケボノ', | |
| 'シラトリ', | |
| ); | |
| for my $katakana ( @katakanas ) { | |
| my $output = sprintf "%s:%s\n", judge_katakana($katakana), $katakana; | |
| print encode('utf8', $output); | |
| } | |
| sub judge_katakana { | |
| my ($katakana) = @_; | |
| for my $key ( keys %{$judging_katakana_list} ) { | |
| my $regexp = $judging_katakana_list->{$key}; | |
| if ( $katakana =~ m{$regexp}xms ) { | |
| return $key; | |
| } | |
| } | |
| return; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment