I use this regularly to compare columns in tab-delimited files. It could be quite easily modified to suit your purposes.

I wouldn't normally just hand you code, but I had this already. If you want the results to go to a file instead of a screen, all you need to do it compcolumns.pl file1 column1 file2 column2 > outputfile.txt:
#! perl -w use strict; my ($file, $col, $file2, $col2) = @ARGV; my (%unique, %unique2); my @column; my ($x, $header); my @fields; # I put something like this in all my scripts so I don't need to remem +ber argument order if ($file eq "?"){ die "usage: compcolumns.pl file1 column1 file2 column2\n"; } ## whenever you open a file, do yourself a favor and tell yourself if +it doesn't open open FIL, $file or die "Could not open $file: $!\n"; $x = 0; %unique=(); while (<FIL>){ chomp; ##The split here, a regular expression, is what you would chan +ge (at least if your data is based on space delimiting instead of tab +-delimiting). @fields = split /\t/; if (defined ($fields[$col]) ){ $header = $fields[$col] if $x == 0; $unique{$fields[$col]}++; } else{ $unique{"BLANK"}++; $header = "BLANK"; } $x++; } open FIL, $file2 or die "Could not open $file2: $!\n"; $x=0; while (<FIL>){ chomp; @fields = split /\t/; if (defined ($fields[$col2]) ){ $header = $fields[$col2] if $x == 0; $unique2{$fields[$col2]}++; } else{ $unique2{"BLANK"}++; $header = "BLANK"; } $x++; } ## The output routine. Note that if something's in both files, it wil +l be printed twice. foreach (sort keys %unique) { if (!exists $unique2{$_}){ print "$_ in $file but not $file2\n"; } else { print "$_ in both files\n"; } } foreach (sort keys %unique2) { if (!exists $unique{$_}){ print "$_ in $file2 but not $file\n"; } else { print "$_ in both files\n"; } }
Since I usually get passed excel files, I haven't had the occassion to work with 190,000 line files. I haven't had any slowness issues, though.

In reply to Re: Seeking guidance on how to approach a task by SamCG
in thread Seeking guidance on how to approach a task by mark_nelson

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.