Skip to content

Instantly share code, notes, and snippets.

@benkasminbullock
Last active August 29, 2015 13:56
Show Gist options
  • Save benkasminbullock/9271428 to your computer and use it in GitHub Desktop.
Save benkasminbullock/9271428 to your computer and use it in GitHub Desktop.
menz.pl
#!/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