#!/usr/bin/perl use strict; use warnings; use CGI qw(:standard :html3); use Algorithm::Diff qw(traverse_sequences); use Text::Tabs; open(OUTPUT, ">out.html"); my $old = '1 2 3 4 6 7 8'; my $new = '1 2 5 3 6 4 7 8'; my @old = split( /\s+/, $old ); my @new = split( /\s+/, $new ); my $style = < "$old vs $new", -style => { -code => $style } } ), h1( { -style => 'margin-left: 24pt' }, span( { -style => 'color: red' }, $old ), span(" vs. "), span( { -style => 'color: blue' }, $new ) ), "\n"; traverse_sequences( \@old, \@new, { MATCH => \&match, DISCARD_A => \&only_old, DISCARD_B => \&only_new, } ); print OUTPUT end_html; sub match { print OUTPUT shift(@old), "\n"; shift(@new); } sub only_old { print OUTPUT "" . shift(@old) . "\n"; } sub only_new { print OUTPUT "" . shift(@new) . "\n"; } close(OUTPUT);