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.