Contrary to an earlier suggestion, I'd read "file 1" first, and store each "user*" string as a hash key -- there will be less data overall to keep in memory.

Then, reading "file 2", only print a line if its first token does not exist as a hash key. These are the records in file 2 that do not exist in file 1.

Put that way, the script can be very short, especially if you just give the file names as command line args:

use strict; die "Usage: $0 file.1 file.2\n" unless ( @ARGV == 2 ); # test for number of args my %known; open( F, "<", $ARGV[0] ) or die "$ARGV[0]: $!"; while (<F>) { chomp; $known{$_} = undef; # don't need a value, just the key } close F; open( F, "<", $ARGV[1] ) or die "$ARGV[1]: $!"; while (<F>) { my $key = ( split ' ', $_ )[0]; # get first "word" print unless exists( $known{$key} ); } close F;
That will print the targeted records to STDOUT, which you can redirect to a file via the command line:
little_perl_script.pl file.1 file.2 > target.set
(update: just noticed that this is identical to TedPride's suggestion, ignoring a few trivial, irrelevant differences. sorry about the redundancy)

In reply to Re: Seeking guidance on how to approach a task by graff
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.