# hepburn2.pl # Converts Japanese text in "official" Monbushoo (Kunrei-shiki) romanization # to more common "Hepburn"-style romanization # A list of differences can be found at: # http://en.wikipedia.org/wiki/Romaji # This version also reads in the "right" answers from a file called # Japanese-Converted.txt, and checks each of its own outputs. $input_file = "Japanese-ToConvert.txt"; open (INFILE, $input_file) or die "Warning! Can't open input file: $!\n"; $check_file = "Japanese-Converted.txt"; open (CHECKFILE, $check_file) or die "Warning! Can't open check file: $!\n"; while ($line = ) { # Crucial rule ordering: this needs to go first $line =~ s/hu/fu/g; # The major difference is use of after t,s,z $line =~ s/ty/ch/g; $line =~ s/sy/sh/g; $line =~ s/zy/j/g; # Also, palatalization before i $line =~ s/ti/chi/g; $line =~ s/si/shi/g; $line =~ s/zi/ji/g; # And assibilation of t before u $line =~ s/tu/tsu/g; print "$line"; # Now check answer against the "real" answer in the checkfile $check_line = ; if ($line eq $check_line) { print "\t(correct)\n"; } else { print "\t(incorrect)\n"; } }