And combining merlyn's and my answers I give you:

#!/usr/bin/perl -w use strict; use Algorithm::Diff qw( traverse_sequences ); exit main(); { my( $outState, %markUp, %htmlEnt ); BEGIN { %markUp= ( same => ['',''], new => ['<strong>','</strong>'], old => ['<font size="-1"><strike>','</strike></font>'], ); %htmlEnt= ( "<"=>"lt", "&"=>"amp", ">"=>"gt", "["=>"#91", "]"=>"#93" ); } sub output { my( $style, $text )= @_; if( ! defined $outState ) { print $markUp{ $outState= $style }[0]; } elsif( $style ne $outState ) { print $markUp{$outState}[1], $markUp{$style}[0]; $outState= $style; } $text =~ s#([][<>&])#&$htmlEnt{$1};#g; $text =~ s#\n#<br>\n#g; print $text; } } sub flush { my( $meth, $rOld, $rNew )= @_; return if "" eq $$rOld && "" eq $$rNew; if( "" eq $$rOld ) { output( "new", $$rNew ); } elsif( "" eq $$rNew ) { output( "old", $$rOld ); } elsif( ! $meth ) { output( "old", $$rOld ); output( "new", $$rNew ); } else { my( $meth, $old, $new )= &$meth( $rOld, $rNew ); compare( $meth, $old, $new ); } $$rOld= $$rNew= ""; } sub compare { my( $meth, $old, $new )= @_; my( $oldTemp, $newTemp )= ( "", "" ); traverse_sequences( $old, $new, { MATCH => sub { flush( $meth, \$oldTemp, \$newTemp ); output( "same", $old->[$_[0]] ) }, DISCARD_A => sub { $oldTemp .= $old->[$_[0]] }, DISCARD_B => sub { $newTemp .= $new->[$_[1]] }, } ); flush( $meth, \$oldTemp, \$newTemp ); } sub SentToWord { my( $rOld, $rNew )= @_; return( undef, [ split /(?<=\s)(?=\S)/, $$rOld ], [ split /(?<=\s)(?=\S)/, $$rNew ], ); } sub ParaToSent { my( $rOld, $rNew )= @_; return( \&SentToWord, [ split /(?<=[.?!]\s)/, $$rOld ], [ split /(?<=[.?!]\s)/, $$rNew ], ); } sub main { die "Usage: $0 old new >dif\n" unless 2 == @ARGV; my( $old, $new ); { local($/,@ARGV)= ('',$ARGV[0]); $old= [<>]; } { local($/,@ARGV)= ('',$ARGV[1]); $new= [<>]; } compare( \&ParaToSent, $old, $new ); output( "same", "" ); exit 0; }

This compares non-HTML files in a way that produces HTML that shows the differences.

Update: I added support for quoting [ and ] and (temporailly) put some sample output from this on my home node.

        - tye (but my friends call me "Tye")

In reply to Re: Finding changed words by tye
in thread Finding changed words by swiftone

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.