#!/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