# populate DISTINCT ids from table into a variable # separated by pipe symbol; variable looks like below # and contains 15000 distinct ids $compare = "F1|FTDR|RJIER|KERF...." # open the file and loop open (MFIL,") { chomp ($lines); $lines =~ m/^$compare/o && next; print $lines,"\n"; } close (MFIL);