#!/usr/bin/perl -w use strict; use Text::CSV; use Tie::File; #load all args to vars my($userCSV, $supCSV, $ufield, $sfield, $output) = @ARGV; #open each file into array for editing tie my(@userList), 'Tie::File', $userCSV or die; tie my(@supList), 'Tie::File', $supCSV or die; tie my(@output), 'Tie::File', $output or die; #load up CSV methods into vars my $uCSV = Text::CSV->new(); my $sCSV = Text::CSV->new(); #each line iterated into the line var foreach my $line (@userList) { #convert line to CSV constructor if($uCSV->parse($line)) { #open a new var and load csv values into it my @userCols = $uCSV->fields(); #run a check against the suppression if(check($userCols[$ufield])) { #write to output push @output, $line; } } } #check if email exists in suppresion list sub check { #var parsed set my($eCheck) = $_[0]; #loop through suppression list and get each line as a var foreach my $line (@supList) { #convert the var into a CSV format if($sCSV->parse($line)) { #convert the my @supCols = $sCSV->fields(); if($eCheck eq $supCols[$sfield]) { print "Busted\n"; return 0; } } } print "Looped\n"; return 1; }