Here's your examples run through a word diff'r by color I had laying around. Maybe this could be a starting point for solving your problem.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11127688 use warnings; use Algorithm::Diff qw(traverse_sequences); use Term::ANSIColor; while( <DATA> ) { my @from = split /(\s+)/; my @to = split /(\s+)/, <DATA>; traverse_sequences( \@from, \@to, { MATCH => sub {print $from[shift()]}, DISCARD_A => sub {print color('red'), $from[shift()], color 'reset +'}, DISCARD_B => sub {print color('green'), $to[pop()], color 'reset'} +, } ); print "\n\n"; } __DATA__ A few moments will suffice to commit it to memory; yet the period whic +h it covers, commencing more than twenty-five centuries ago, reaches +on from that far-distant point past the rise and fall of kingdoms, pa +st the setting up and overthrow of empires, past cycles and ages, pas +t our own day, over into the eternal state. A few moments will suffice to commit it to memory, yet the period whic +h it covers, beginning more than twenty-five centuries ago, reaches f +rom that far-distant point past the rise and fall of kingdoms, past t +he setting up and overthrow of empires, past cycles and ages, past ou +r own day, to the eternal state. Now opens one of the sublimest chapters of human history. Now opens one of the most comprehensive of the histories of world empi +res. With what interest, as well as astonishment, must the king have listen +ed, as he was informed by the prophet that he, or rather his kingdom, + the king being here put for his kingdom (see the following verse), w +as the golden head of the magnificent image which he had seen. With what interest and astonishment must the king have listened as he +was informed by the prophet that his kingdom was the golden head of t +he magnificent image.

In reply to Re: Comparing two text files and marking differences by tybalt89
in thread Comparing two text files and marking differences by Polyglot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.