As is oftne the case, the data structure you use makes a world of difference. In this case, I'd recommend a hash of the IP addresses found in file1. You could also store the actual line that triggered it for diagnostics, reporting, or debugging. This first example just records that file1 had the IP present.

my %hash; while ( my ( $ip, $other_stuff ) = parse_values_file_1() ) { $hash{ $ip } = 1; } while ( my ( $ip, $other_stuff ) = parse_values_file_2() ) { print "Not found: $ip ($other_stuff)\n" unless $hash{ $ip }; }

I'll leave the implementation of the parsing as an exercise for now. What you have here is a check for uniqueness. Whenever you think "uniqueness test" and "Perl", think "I can probably use a hash for that".


In reply to Re: Return rows from 2 csv files that don't match by mr_mischief
in thread Return rows from 2 csv files that don't match by meredib

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.