# diffs two files and writes an HTML output file.
use CGI
qw(:standard :html3);
use Algorithm
::Diff
'traverse_sequences';
# Take care of whitespace.
@
$arrayRef = expand
(@
$arrayRef);
# This will be called with both lines are the same
print pre
( $a[$ia] ), "\n";
# This will be called when there is a line in A that isn't in B
print pre
( { -class => 'onlyA' }, $a[$ia] ), "\n";
# This will be called when there is a line in B that isn't in A
print pre
( { -class => 'onlyB' }, $b[$ib] ), "\n";
# Check for two arguments.
print "usage: $0 file1 file2 > diff.html\n" if @ARGV != 2;
$tabstop = 4; # For Text::Tabs
# Read each file into an array.
font-family: Courier, monospaced;
PRE.onlyB { color: blue }
# Print out the starting HTML
-title
=> "$ARGV[0] vs. $ARGV[1]",
-style
=> { -code
=> $style }
{ -style
=> 'margin-left: 24pt' },
span
( { -style
=> 'color: red' }, $ARGV[0] ),
span
( { -style
=> 'color: blue' }, $ARGV[1] )
MATCH
=> \
&match
, # callback on identical lines
DISCARD_A
=> \
&only_a
, # callback on A-only
DISCARD_B
=> \
&only_b
, # callback on B-only