myfrndjk has asked for the wisdom of the Perl Monks concerning the following question:
Hi i want to compare two html files character by character and print the difference if there is any difference between two files.Thanks
use strict; use warnings; use List::Compare; use LWP::Simple; open F,"<","C:/Users/jeyakuma/Desktop/shipping project/changed co +ntents/file1.html" ; open S, "<","C:/Users/jeyakuma/Desktop/shipping project/database/fi +le2.html" ; my @a=<F>; my @b=<S>; my $lc = List::Compare->new(\@a,\@b); my @intersection = $lc->get_intersection; my @firstonly = $lc->get_unique; my @secondonly = $lc->get_complement; print "Common Items:\n"."@intersection"."\n"; print "only in file\n"."\n@firstonly"."\n"; print "only in file1 \n"."\n@secondonly"."\n";
file1
There are 2 mangoes in the basket and There are two apples in the basket
file2
They are 3 mangoes in the basket and They are six grapes in the basket
Expected output
only in file1-->2, two
only in file2-->3 six grapes
common content in both -->There are mangoes in the basket and There are apples in the basket
current result
only in file1
There are 2 mangoes in the basket and There are two apples in the basket
only in file2
They are 3 mangoes in the basket and They are six grapes in the basket
common
(blank)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: compare and find difference between two files
by GotToBTru (Prior) on Jul 14, 2014 at 18:18 UTC | |
by myfrndjk (Sexton) on Jul 14, 2014 at 18:48 UTC | |
|
Re: compare and find difference between two files
by zentara (Cardinal) on Jul 14, 2014 at 17:59 UTC | |
|
Re: compare and find difference between two files
by Anonymous Monk on Jul 14, 2014 at 20:09 UTC | |
by Bethany (Scribe) on Jul 15, 2014 at 01:30 UTC | |
by mr_mischief (Monsignor) on Jul 16, 2014 at 13:45 UTC | |
by Bethany (Scribe) on Jul 16, 2014 at 13:55 UTC | |
by mr_mischief (Monsignor) on Jul 17, 2014 at 14:44 UTC | |
|