8. Example V: compare two strings


use String::Diff; # https://metacpan.org/pod/String::Diff
($original, $revision) = String::Diff::diff('This software can find revisions between 2 versions of a same text.', 
                                            'This software can find all revisions between two versions of a same document.');
print "$original\n"; # This software can find revisions between [2] versions of a same [t]e[x]t.
print "$revision\n"; # This software can find {all }revisions between {two} versions of a same {docum}e{n}t.
The old and new strings can be merged:

use String::Diff;
$diff = String::Diff::diff_merge('This software can find revisions between 2 versions of a same text.', 
                          'This software can find all revisions between two versions of a same document.');
print "$diff\n"; # This software can find {all }revisions between [2]{two} versions of a same [t]{docum}e[x]{n}t.