[lug] parsing between two lists
Tkil
tkil at scrye.com
Wed Mar 27 12:25:25 MST 2002
>>>>> "Rob" == Rob Nagler <nagler at bivio.biz> writes:
>> ...but I would rather have a list that shows what's in fileA that's not
>> in fileB:
Rob> I just had this problem yesterday. Here is a very quick hack:
Rob> #!/usr/bin/perl -w
Rob> my($FILE_A) = {};
Rob> open(IN, 'file_a.txt') || die("open 'file_a.txt': $!");
Rob> while (<IN>) {
Rob> chomp;
Rob> next unless $_;
Rob> $FILE_A->{lc($_)}++;
Rob> }
Rob> close(IN) || die;
Rob> open(IN, 'file_b.txt') || die("open 'file_b.txt': $!");
Rob> while (<IN>) {
Rob> chomp;
Rob> next unless $_;
Rob> delete($FILE_A->{lc($_)});
Rob> }
Rob> print join("\n", sort(keys(%$FILE_A))), "\n";
any particular reason you're using hash refs here, instead of simple
hashes?
just curious,
t.
More information about the LUG
mailing list