Showing differences between $Input1 and $Input2
"); print(""); if ($showThreshold == 0) { print "Showing all changes. "; } else { print "Hiding changes smaller than $showThreshold%. "; } print "Highlighting changes larger than $highlightThreshold%."; print "
\n"; if ($excludeNoHighlight) { print ("Excluding rows that have no highlighted cells
\n"); } elsif ($excludeNoShow) { print ("Excluding rows that have no significant difference
\n"); } print ""; my $showCells = 0; my $highlightCells = 0; foreach my $Field (@Fields) { if ($Field =~ /[\s|]+/) { # If it's a seperator, just output it #print $Field; $row .= " | "; } else { # If it's not a seperator, diff it... my $Show = 0; my $Highlight = 0; my $Colour = 0; if (@FieldsCompare > $FieldNo) { my $FieldComp = $FieldsCompare[$FieldNo]; if ($Field =~ /^[0-9.]+$/ && $FieldComp =~ /^[0-9.]+$/ && $FieldComp != 0 && $Field ne $FieldComp) { # Handle numbers special # How much did the field change? my $Change = $Field/$FieldComp; # Check to see if the change is really small, don't show it # then. $Show = 1 if ($Change > 1 + ($showThreshold / 100) || $Change < 1 - ($showThreshold / 100)); # Highlight the change if it is large enough, both relatively # and absolutely $Highlight = 1 if ($Change > 1 + ($highlightThreshold / 100) || $Change < 1 - ($highlightThreshold / 100)); $Highlight = 0 if (abs($Field - $FieldComp) < $highlightAbsDiff); # Show and colour changes if the change is large enough if ($Show) { my $Percent = sprintf("%+.2f%%", ($Change-1)*100); $Field = "$FieldComp => $Field ($Percent)"; $Colour = ($Change > 1 ? "red" : "green"); } } elsif ($Field ne $FieldComp) { $Show = 1; # Specially handle tests that are failing to compile but were not # doing so previously if ($Field eq "*") { $Highlight = 1; $Colour = "red"; $Field = "FAIL"; } # Always show but never highlight other changes in non-numeric # fields $Field = "$FieldComp => $Field"; } } # Remove spaces, we don't want wrapping inside cells $Field =~ s/ /\ /g; $row .= "" if $Highlight; $row .= "" if $Colour; $row .= $Field; $row .= "" if $Colour; $row .= "" if $Highlight; # Keep track that at least one cell was shown/highlighted in this # row. $highlightCells = 1 if ($Highlight); $showCells = 1 if ($Show); $FieldNo++; } } $row .= " |