in reply to Problems in comparing two files written in Japanese

Rather than inventing your own Diff-algorithm, have a look at Algorithm::Diff.

it doesn't show the differences properly....keeps showing odd symbols instead of the japanese characters
I do not think it has something to do with your diff-algorithm, but rather with your output device not working with the right character set or the font used does not have the correct representation of some characters. perldoc perlunicode and perldoc perluniintro

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James