Comparing file contents, the perl way

[email protected] (beast)
Newsgroups perl.beginners
Message-ID <[email protected]>
Good morning,

I have 2 files which contains some IDs. Basically I want to search ID
in the file A which is missing on the file B.

This program is ugly, but its work :-)
------------
use strict;

my $target_file = "B.txt";
while(<>) {
   chomp;
   my $res = `grep $_ $target_file`;
   print "$_ is missing\n" if ! $res;
}
------------

I'm trying to found another solutions which more perlish and efficient.
So far im relying that ID should be same digits on the both file,
because "123" will match "1234" :-(

File contents is around 20k - 30k lines, so i must consider the
performance and memory usage also.

A.txt
-----
12345
56789
32134
62134
42134
52134
12234

B.txt
-----
12234
42134
82134
32134


Thanks.

--budhi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.