in reply to Re^2: comparing any two text files and writing the difference to a third file
in thread comparing any two text files and writing the difference to a third file

But currently I am learning perl, a total beginner. I did my basic lessons and was trying to give myself a challenge with this program.
I think you've picked a rather challenging problem to solve in the general sense. This is the sort of thing that sounds easy when viewed from 30,000 feet, but from 50 feet, a lot of details emerge. Hey, those things that looked like ants are really people...etc...

I briefly perused the code presented by Hippo at Re: comparing any two text files and writing the difference to a third file. It appears to be well structured and well commented. A lot could be learned by intense study and experimentation with this code. I would add print statements to try to understand what each part is doing. There are some constructs that I would not expect a beginner to come up with, but study of this code would be instructive.

When faced with a complex problem, one idea is to simplify and solve a related, but less complex problem. One of the issues with file level diff is re-synchronization after a different block of lines is detected. How about just working with pairs of lines (and words within those lines) to start with?

  1. Bob went to the store.
  2. Bob and Mary went to the store.
Sentence (2) has "and Mary " as an addition.
If the sentences are swapped, then sentence (2) has "and Mary " as a deletion.
Work out some way to represent that.

What about a "substitution"?.
This might have to be represented as a deletion and an addition?

  1. Bob went to the store.
  2. Bob went to the movies.
Or perhaps:
  1. Bob went to the store and then to the bar for happy hour drinks.
  2. Bob and Mary went to the movies and then to the bar.
Anyway, the ideas is to work on a more constrained problem that illustrates at least some of the difficulties of the more general problem. My examples might not be the best, but I hope my idea is clear.
  • Comment on Re^3: comparing any two text files and writing the difference to a third file