I have two files, for the sake of argument we'll call them "old.txt" and "nex.txt". It's a series of records, one per line, of variable length.
I want to compare both the files and then have a list of entries in a new file ("changes.txt").
So for the sake of example, my first file ("old.txt") is thus :
Code:
1. This is the first line of the file.
5. This is the FIFTH line of the file.
3. This is the third line of the file.
4. This is the fourth line of the file.
2. This is the second line of the file.
6. This is the seventh line of the file.
My second file ("new.txt") is thus :
Code:
1. This is the first line of the file.
2. This is the second line of the file.
3. This is the third line of the file.
4. This is the fourth line of the file.
5. This is the fitfh line of the file.
6. This is the sixth line of the file.
7. This is the seventh line of the file.
8. This is the eight line of the file.
I'm not interested in what order the lines appear in, so ultimately I'd want the output to look like :
Code:
5. This is the fitfh line of the file.
6. This is the sixth line of the file.
7. This is the seventh line of the file.
8. This is the eight line of the file.
Because they're the changes, i.e. records in "new.txt" that aren't in "old.txt". Any ideas?
Obviously I'm trying to read both files into respective arrays, and then comparing the elements one by one, deleting all duplicate records as I go, but my array handling in Perl is rusty to say the least so I keep getting nonsense output. This seems like a staggeringly easy task but I've been staring at this for an hour now with no progress.
Help plz.