compare apache lib-simulate grep -search A.txt lib in B.txt

来源:互联网 发布:qq音乐 for ubuntu 编辑:程序博客网 时间:2024/06/05 19:51
#!/usr/bin/perl -wmy $file=$ARGV[0];my $file1=$ARGV[1];$file2 ="found.txt";$file3 ="nofound.txt";open($fh,'<',$file) or die $!;open($fh1,'<',$file1) or die $!;open($fh2,'>',$file2) or die $!;open($fh3,'>',$file3) or die $!;my @list="";$j=0;while ($line=<$fh>) {        if ($line =~ /.*\\(mod.*)/)        {                $a=$1;                #######################################                #consult don;t add \n ,all array list print in one line??????????????                $a=$a."\n";                push (@list ,$a);                $j++;                #can;t use print @list to print array                #foreach(@list)                #{                #       print "line16:$_\n";                #}        }}while ($line1=<$fh1>) {        push @list1 ,$line1;}$found=0;$nofound=0;my @found1="";my @nofound1="";$ii=0;print @list;foreach (@list){        $ii++;        $a = $_;        if ( $a eq "" )        {                next;        }        #success use grep , key is use (),otherwise it don;t get element ,it get all array        @f= (grep  /$a/,  @list1);        if (@f)        {                $found++;                push (@found1,$a);                print $fh2 $a;        }        else        {        #attention    print "line27:$a \n"; the space will also been printed.                $nofound++;                push @nofound1 ,$a;                print $fh3 $a;        }}my $aa=@found1;my $bb=@nofound1;print "found=$found;nofound=$nofound;$aa;$bb\n";print ("@found1");print ("@nofound1");

阅读全文
0 0
原创粉丝点击