HDR,831 Reconciliation,200008081441EST BGN,11,000000158,20000808,10520000 OTI,GH,BT,WEDI620000802,159 AMT,2,231644 AMT,BT,231644 AMT,NP,0 QTY,46,10 QTY,53,0 QTY,54,10 QTY,55,0 TED,ZZZ,BATCH AWAITING 831 OTI,TR,CK,0021000095,159,000101416 TED,ZZZ,MOD CHECK ON RDFI-ID FAILED #### #!/usr/local/bin/perl5 #PERL Script #1. Input the text file containing the formatted info open (FILE,"<824.txt") || die "Can't open file $!"; @lines = ; #initialize the counters $HDRcount = 0; $BGNcount = 0; $OTIcount = 0; $AMTcount = 0; $QTYcount = 0; $TEDcount = 0; #Create the main array foreach (@lines) { chop; ($key, $first, $second, $third, $fourth, $fifth) = (split(/,/)); $key = "" if !defined($key); #I know this part isn't needed but i'd rather not get errors $first = "" if !defined($first); $second = "" if !defined($second); $third = "" if !defined($third); $fourth = "" if !defined($fourth); $fifth = "" if !defined($fifth); $sixth = "" if !defined($sixth); print("Key=$key 1=$first 2=$second 3=$third 4=$fourth 5=$fifth\n"); #Search through firstElementArray counting up each instance of # HDR, BGN, OTI, AMT, QTY, TED if ($key eq "HDR") { $HDRcount++; #create an array here, similiar to @HDR($first, $second, $third) } $BGNcount++ if ($key eq "BGN"); $OTIcount++ if ($key eq "OTI"); $AMTcount++ if ($key eq "AMT"); $QTYcount++ if ($key eq "QTY"); $TEDcount++ if ($key eq "TED"); } #test to make sure it works print("HRD=$HDRcount BGN=$BGNcount OTI=$OTIcount AMT=$AMTcount QTY=$QTYcount TED=$TEDcount\n"); close(FILE);