Hi All looking for help with a script that looks to a csv file to determine how to parse another file in order to get an end value. Table: #PTC,FTC,QUAN,QSIGN,AMT,ASIGN,ST ADM,RCV,,+,,, ADM,DLV,,,,, ABC,EFG,,,,,8 ABC,XYZ,,-,,,7 for the first example: if field1 ne "" field4 ne "" then I want to build a statement using the 3 fields that are populated: if ($CODE1 eq "$field1") && ($CODE4 eq "$field4) { $TRN = "$field2"; } if field1 ne "" field7 ne "" if ($CODE1 eq "$field1") && ($CODE7 eq "$field7) { $TRN = "$field2"; } if field1 ne "" if ($CODE1 eq "$field1") { $TRN = "$field2"; } The $CODE* fields are fields I have already parsed from a line in a text file and then if there is a match assign $TRN. Trying to avoid having to right 100s of if statements for each possible scenario. &GetTrnCode($X); sub GetTrnCode ($) { $CODE = ""; $TRANCODE = ""; $PERcode=""; $FDXcode=""; $CODE = $_[0]; my %TrnCode; $data2 = "PerTrnTable.txt"; open(inData2, $data2); while () { chomp; $line2 = $_; my $PERcode = (split(/,/,$line2))[0]; my $FDXcode = (split(/,/,$line2))[1]; my $QUANTITY1 = (split(/,/,$line2))[2]; my $QSIGN1 = (split(/,/,$line2))[3]; my $AMT1 = (split(/,/,$line2))[4]; my $ASIGN = (split(/,/,$line2))[5]; my $SECTYPE1 = (split(/,/,$line2))[6]; if (($CODE eq $PERcode) && ($QSIGN eq $QSIGN1) && ($AMTSIG eq $ASIGN) && ($SECTYPE eq $SECTYPE1)){ $TRNCODE = $FDXcode; } } } close inData2; } This is where I am at, but In many it does not matter what each field is so I do not want to compare fields if in the table the field is blank. in this example it would return TRN = RCV and DLV, which is not what I want to do. I would want to return TRN = DLV because the other fields in the table are blank if ($CODE1 eq "$field1") { $TRN = "$field2"; } Thanks in advace,