You could load the accounts into a lookup table (a hash), loop over the csv file and test if an account exists. If it doesn't write the data to another file.

Here is one way you could do that:

#!/usr/bin/perl use strict; use warnings; open my $accnts, '<', 'accounts.txt' or die "can't open accounts.txt: $!"; my %lookup = map {chomp; $_ => undef} <$accnts>; open my $csv, '<', 'csv.txt' or die "can't open csv.txt: $!"; open my $output, '>', 'output.txt' or die "can't open output.txt: $!"; while (my $record = <$csv>){ chomp $record; # change to suit the order of the fields my ($file, $accnt, undef, undef, undef) = split /,/, $record; next if exists $lookup{$accnt}; print $output "$file -> $accnt\n"; } =pod accounts.txt acnt1 acnt2 acnt3 acnt4 csv.txt fil1,acnt1,col3,col4,col5 fil2,acnt2,col3,col4,col5 fil3,acnt3,col3,col4,col5 fil4,acnt4,col3,col4,col5 fil5,acnt5,col3,col4,col5 fil6,acnt6,col3,col4,col5 fil7,acnt7,col3,col4,col5 fil8,acnt8,col3,col4,col5 fil9,acnt9,col3,col4,col5 output.txt fil5 -> acnt5 fil6 -> acnt6 fil7 -> acnt7 fil8 -> acnt8 fil9 -> acnt9 =cut

Hope that helps

update: Tested :-)


In reply to Re: removing same entries between 2 files by wfsp
in thread removing same entries between 2 files by sbp

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.