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)


In reply to compare and find difference between two files by myfrndjk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.