# hepburn.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

$input_file = "Japanese-ToConvert.txt";
open (INFILE, $input_file) or die "Warning! Can't open input file: $!\n";

while ($line = <INFILE>) {
    # Crucial rule ordering: this needs to go first
    $line =~ s/hu/fu/g;

    # The major difference is use of <y> 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"; 
}