LAdProg2005
Programmer
I am using simple script to check difference in two files as bellow
File 1:
apple|1
banana|1
kiwi|3
File 2:
banana|2
kiwi|3
when running result is
apple|1 - removed in file 2
banana|1 - changed in file 2
by looking at the records you can't tell if the line was updated or deleted....
how do i differeciate between which record is deleted and which is changed? i can tell with the above data because it is couple lines , but for many lines it would not be good to eyeball...
thanks,
LAd
Code:
#!/usr/bin/perl
open a, "$ARGV[0]";
open b, "$ARGV[1]";
local $/; my @a = split /\n/, <a>;
my @b = split /\n/, <b>;
my %b = map { $_ => 1 } @b;
# Make hash of B
my @res = grep { !defined $b{$_} } @a;
# Everything in A not in B
print join "\n", @res; print "\n";
File 1:
apple|1
banana|1
kiwi|3
File 2:
banana|2
kiwi|3
when running result is
apple|1 - removed in file 2
banana|1 - changed in file 2
by looking at the records you can't tell if the line was updated or deleted....
how do i differeciate between which record is deleted and which is changed? i can tell with the above data because it is couple lines , but for many lines it would not be good to eyeball...
thanks,
LAd