in reply to Comparing the contents of two files
I'd try to look on CPAN for solutions or partial solutions, like Algorithm::Diff or Text::WordDiff.