Good code.
However, you said that you knew no way to "tell Text::Diff to ignore trailing blanks as being insignificant." I decided to explore this and found that the following code works:
#!/usr/bin/env perl
die "Usage: $0 from-file to-file\n"
unless @ARGV == 2;
use Text::Diff;
diff shift, shift,
{ OUTPUT => \*STDOUT,
STYLE => "OldStyle", # or whatever pleases you
KEYGEN => sub{ (my $line = shift) =~ s/\s*$//; return $line; },
};
In general, to compare something other than the lines themselves, just return that from the KEYGEN argument. For example, inserting sub{return substr shift, 0, 1} compares only the first characters. Unfortunately, the documentation for this is hidden in Algorithm::Diff. | [reply] [d/l] [select] |
I like your script for its simplicity if one wants a quick answer to what lines differ.
Having read that you don't have Cygwin installed, I strongly recommend that you or anybody else does so. Or install GNU utilities for Win32. Once you start to think that you need to write these types of scripts, it would be worth it to install Cygwin. It has saved me countless hours of trying to write my own stuff that already exists on a *nix system.
I write this because my hope is that it will help many others too.
Lupey
unashamed Cygwin advocate | [reply] |