Last active
August 29, 2015 13:56
-
-
Save benkasminbullock/9271428 to your computer and use it in GitHub Desktop.
menz.pl
This file contains 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
#!/home/ben/software/install/bin/perl | |
use warnings; | |
use strict; | |
use Lingua::JA::Moji ':all'; | |
binmode STDIN, ":encoding(UTF-8)"; | |
binmode STDOUT, ":encoding(UTF-8)"; | |
while (<STDIN>) { | |
if (/^(\S+)\s+\[(\p{InKana}+)\]/) { | |
print "$2\t$1\n"; | |
} | |
elsif (/^(\p{InHiragana}+)\s+/) { | |
print "$1\t$1\n"; | |
} | |
elsif (/^(\p{InKatakana}+)\s+/) { | |
next; | |
} | |
else { | |
chomp; | |
print STDERR "$.: $_ unmatched\n"; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment