Hi All looking for help with a script that looks to a csv file to dete +rmine 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 te +xt file and then if there is a match assign $TRN. Trying to avoid having to right 100s of if statements for each possibl +e scenario. &GetTrnCode($X); sub GetTrnCode ($) { $CODE = ""; $TRANCODE = ""; $PERcode=""; $FDXcode=""; $CODE = $_[0]; my %TrnCode; $data2 = "PerTrnTable.txt"; open(inData2, $data2); while (<inData2>) { 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 $ASIG +N) && ($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 bl +ank. 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 field +s in the table are blank if ($CODE1 eq "$field1") { $TRN = "$field2"; } Thanks in advace,

In reply to Building If Statements by mmittiga17

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.