use strict; use warnings; #### use strict; use warnings; # Read the values from XREF into a hash my $xref = "input_file.txt"; # put here real filename open my $XREF, "<", $xref or warn "Could not open $xref $!"; # A more detailed message can sometimes be useful my %xreflines = map { chomp; $_ => 1 } grep /\S/, <$XREF>; # populating the hash with the content of the xref file close $XREF; my $goodfile = ...; # insert the name of the output file here open my $XFILE, ">>", $goodfile or warn "Could not open $goodfile $!"; my $outfile = ...; # insert the name of the customer file here open my $CUSTOMERFILE, "<", $outfile or warn "Could not open $outfile $!"; while (my $line = <$CUSTOMERFILE>) { my ($dist, $cust) = (split /;/, $line)[0,1]; # no need to chomp the fields, there are other fields afterwards in the line my $key = "$dist$cust"; # Building the lookup key unless (exists $xreflines{$key}) { # hash lookup print $XFILE "$line"; # printing the lines whose ID is not found in the cross ref file } } close $XFILE; close $CUSTOMERFILE;