hi,

Is there a best way to find some lines which exists in both two files?
Someone has show me a method but it seems a little low efficiency.
The code is as below:

open (T1,"1.txt") or die "$!";
open (T2,"2.txt") or die "$!";

while(my $line=<T2>){
  chomp $line;
  print $line,"\n" unless diff($line);
}

sub diff
{
   my $line=shift;
   my $ok=0;
   while(<T1>){
       chomp;
       if ($_ eq $line)
       {
           $ok=1;
           last;
       }
   }
   return $ok;
}

close T2;
close T1;

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to