whittick has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have a bit of script that's supposed to compare two files which are fairly identical, at the moment it's outputting the whole contents of the second file though and I really have no idea why.
use warnings; use strict; use File::Compare; use Text::Diff; use lib "E:\\Program Files (x86)\\Traverse\\lib\\perl"; use lib "C:\\Perl"; my $expect = `expect.expect`; chdir $ARGV[0]; rename "output.new","output.old"; open DIFF, ">alarm.log" or die $!; open OUTPUT, ">output.new" or die $!; print OUTPUT "$expect\n"; if (compare("1.log","2.log") == 0) { print "They're equal\n"; } else { print "They are NOT equal\n"; print DIFF "------------------------------------------------------ +-------------------------------------------------------------\n"; + print DIFF "The script has identified the following changes:\n\n"; + my $diff = diff "output.new", "output.old", { STYLE => "Unified" , + OUTPUT => \*DIFF }; print DIFF "------------------------------------------------------ +-------------------------------------------------------------\n\n"; + close(DIFF); }
If I've missed anything glaringly obvious then please let me know, I can add the files to compare if needed but like I said, they're identical apart from 2 or three lines.
Thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Text::Diff help
by moritz (Cardinal) on Feb 23, 2012 at 10:39 UTC | |
by choroba (Cardinal) on Feb 23, 2012 at 10:43 UTC | |
Re: Text::Diff help
by jethro (Monsignor) on Feb 23, 2012 at 10:54 UTC | |
by whittick (Acolyte) on Feb 23, 2012 at 11:35 UTC | |
by whittick (Acolyte) on Feb 23, 2012 at 11:41 UTC |