#!/usr/bin/perl use strict; use warnings; use CGI qw(:standard :html3); use Algorithm::Diff qw(traverse_sequences); use Text::Tabs; my $old = '1,2,3,4'; my $new = '5,6,7,8'; my @old = split( /\s+/, $old ); my @new = split( /\s+/, $new ); my $style = <<EOS; PRE { margin-left: 24pt; font-size: 12pt; font-family: Courier, monospaced; white-space:pre } PRE.onlynew { color: red } PRE.onlyold { color: blue } EOS print start_html( { -title => "$old vs $new", -style => { -code => $style } } ), h1( { -style => 'margin-left: 24pt' }, span( { -style => 'color: red' }, $old ), span(" <i>vs.<i> "), span( { -style => 'color: blue' }, $new ) ), "\n"; traverse_sequences( \@old, \@new, { MATCH => \&match, DISCARD_A => \&only_old, DISCARD_B => \&only_new, } ); print end_html; sub match { print @old, "\n"; } sub only_old { print "<strong><font color=red>" . shift(@old) . "</font></strong> +\n"; } sub only_new { print "<strong><font color=blue>" . shift(@new) . "(</font></stron +g>\n"; }
In reply to Re: Traverse Sequences in Algorithm::Diff module
by Khen1950fx
in thread Traverse Sequences in Algorithm::Diff module
by dPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |