[lug] parsing between two lists

Rob Nagler nagler at bivio.biz
Wed Mar 27 08:04:37 MST 2002


> ...but I would rather have a list that shows what's in fileA that's not
> in fileB:

I just had this problem yesterday.  Here is a very quick hack:

#!/usr/bin/perl -w
my($FILE_A) = {};
open(IN, 'file_a.txt') || die("open 'file_a.txt': $!");
while (<IN>) {
    chomp;
    next unless $_;
    $FILE_A->{lc($_)}++;
}
close(IN) || die;

open(IN, 'file_b.txt') || die("open 'file_b.txt': $!");
while (<IN>) {
    chomp;
    next unless $_;
    delete($FILE_A->{lc($_)});
}
print join("\n", sort(keys(%$FILE_A))), "\n";





More information about the LUG mailing list