比较两个html文件和print common,仅在file1中的字符串,仅在file2中的字符串

时间:2014-07-14 12:15:31

标签: perl compare

我想比较2个html文件并打印常见项目,仅第一个文件中的字符串,仅第二个文件中的文件,即使2个文件只有一个字符不同。我想打印差异。

    use strict;
    use warnings;
    use List::Compare;
    use LWP::Simple;




    open F, "<C:/Users/jeyakuma/Desktop/shipping project/changed  contents/file1.html" ;
   open S, "<C:/Users/jeyakuma/Desktop/shipping project/database/file2.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 "OLD data!!\n"."\n@firstonly"."\n";
    print "New Data !!\n"."\n@secondonly"."\n";

文件1

篮子里有2个芒果,篮子里有两个苹果

file2的

篮子里有3个芒果,篮子里有6个葡萄

预期输出

仅限于file1 - &gt; 2,两个

仅在file2 - &gt; 3六个葡萄

两者中的常见内容 - &gt;篮子里有芒果,篮子里有苹果

当前结果

仅在file1

 篮子里有2个芒果,篮子里有两个苹果

仅限于file2

篮子里有3个芒果,篮子里有6个葡萄

通用

(空白)

0 个答案:

没有答案
相关问题