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; } }

DWIM is Perl's answer to Gödel

In reply to Re: comparing lists by GrandFather
in thread comparing lists by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.