There's an alternative to do this kind of thing with the standard unix text utilities instead of perl. Of course, you might not want to do that if you want to learn perl.

So here's the method.

[am]king ~/a/tm$ cat emails user01 user01@emailaddress.com user03 user03@emailaddress.com user04 user04@emailaddress.com [am]king ~/a/tm$ cat names user01 user02 user03
First, you sort the two files on their first field. They appear sorted in this example, but it's always best to go for sure.
[am]king ~/a/tm$ sort -k1 emails > emails.sort [am]king ~/a/tm$ sort -k1 names > names.sort
Then, you use join to find the unpairable names in emails.sort.
[am]king ~/a/tm$ join -v1 -o0 emails.sort names.sort user04
You might also be able to use the comm utility instead of join. Update 2009 sep 2.

See Re^2: Joining two files on common field for a list of other nodes where unix textutils is suggested to merge files.


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