Hello
lonnie,
I'm not sure that I completely understand your example. The data in GoodFile.txt and BadFile.txt differ on line 2, so I would expect that difference to show up in Output.txt. However, in your example it does not.
Here is some code that uses Algorithm::Diff to calculate the diff, with some help from Path::Tiny to get the file contents.
This code,
#!/usr/bin/env perl
use strict;
use warnings;
use Path::Tiny;
use Algorithm::Diff qw/diff/;
my @lines1 = path('GoodFile.txt')->lines;
my @lines2 = path('BadFile.txt')->lines;
my $diff = Algorithm::Diff->new( \@lines1, \@lines2 );
while( $diff->Next() ){
next if $diff->Same();
print $diff->Items(2), "\n";
}
exit;
gives the following output:
This section is the description of the animal bla bla lbas.....bla bla
+ lbas.....
Amimal, cat, 3, 4, YELLOW LEG 3, HIGH 'this is a cattt 1
This section is the description of the animal bla bla lbas.....bla bla
+ lbas blaaaal........
UPDATE: The OP made edits to their node, and removed their input data. Here is the input data that I used for my code example (which the OP had provided in the first version of their post).
GoodFile.txt
Amimal, cat, 1, 4, YELLOW HAIR 3, HIGH 'this is a cattt 1
This section is the description of the animal bla bla lbas.....
Amimal, dog, 2, 4, BLACK HEAD 1, HIGHf'this is a doggg 2
This section is the description of the animal bla bla lbas.....
BadFile.txt
Amimal, cat, 1, 4, YELLOW HAIR 3, HIGH 'this is a cattt 1
This section is the description of the animal bla bla lbas.....bla bla
+ lbas.....
Amimal, cat, 3, 4, YELLOW LEG 3, HIGH 'this is a cattt 1
This section is the description of the animal bla bla lbas.....bla bla
+ lbas blaaaal........