Compared with file I/O manipulating hashes is cheap. Something like this perhaps:
use warnings; use strict; open inFile, '<', "accts_to_exclude.txt" || die "Cannot open accts_to_ +exclude.txt"; my %excludeList = map {chomp; $_ => undef} <inFile>; close inFile; open inFile, '<', "list1.txt" || die "Cannot open list1.txt"; my %acctList = map {chomp; $_ => undef} <inFile>; close inFile; open inFile, '<', "list2.txt" || die "Cannot open list2.txt"; my %diffList = map {chomp; $_ => undef} <inFile>; close inFile; open inFile, '<', "list3.txt" || die "Cannot open list3.txt"; my %nameList = map {chomp; $_ => undef} <inFile>; close inFile; open orgAcctList, '<', "orig_accts.txt" || die "Cannot open orig_accts +.txt"; open outFile, '>', 'output.txt' || die "Cannot open output file output +.txt"; while (my $line = <orgAcctList>){ chomp $line; my ($filename, $state, $amt, $ttl, $account, $name, $invnum) = spl +it /\t/, $line; next if exists $excludeList{$account}; print outFile "$filename $state $amt $ttl $account $name $invnum\n +"; if (defined $acctList{$account}) { # do something (write this info to file1) next; } if (defined $diffList{$account}) { # do something (write this info to file2¡K) next; } if (defined $nameList{$name}) { # do something (write this info to file2) last; } }
In reply to Re: comparing lists
by GrandFather
in thread comparing lists
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |