but I can't find my way to complete this task. From the following csv file 
I need to print just the lines for which the sum of the seventh element for 
this same fourth element is >= 3 (e.g.), the third element is in dopo.csv 
and the fifth element is not in nostock.csv:
3,1000000015,R518672,206,HAVCONSTRUCTION,17.99,1,05,17,00
3,1000000015,R518672,305,HAVCASTLE,17.99,1,05,17,00
3,1000000015,R518672,305,HAVRADIORACERS,17.99,1,05,17,00
3,1000000015,R518672,305,STRHOLISTIC,16.29,1,05,17,00
3,1000000015,R518672,305,TLCBARBIESTORY,13.49,1,05,17,00
3,1000000015,R518672,320,BANFIRSTCKBK,22.49,1,05,17,00
3,1000000015,R518672,320,FNW10MINUTE,17.19,1,05,17,00
3,1000000015,R518672,320,MACHOUSE,35.99,1,05,17,00
3,1000000015,R518672,320,MERNEWDECORATIN,31.49,1,05,17,00
3,1000000015,R518672,320,STRSMALL,22.49,3,05,17,00
3,1000000015,R518672,329,COSCREATIVEROOM,16.29,1,05,17,00
3,1000000015,R518672,329,FNWDISPLAY,15.29,2,05,17,00
3,1000000015,R518672,329,HAVEASYFAMILY,13.49,1,05,17,00
3,1000000015,R518672,329,SCHPRISONER,17.99,1,05,17,00
3,1000000015,R518672,329,STRSMALL,22.49,2,05,17,00
3,1000000015,R518672,329,TLCBARBIESTORY,13.49,1,05,17,00
3,1000000015,R518672,329,WARLITTLEMEALS,13.49,1,05,17,00

So far I've done the following:
open(DOPO, "< $dir1/dopo.csv")                          || die "can't open 
dopo for reading: $_!";
open(NOSTOCK, "< $dir1/nostock.csv")            || die "can't open 
nostock.csv for reading: $_!";
open(ORD, "< custord2")                                         || die 
"can't open custord2 for reading: $_!";
open(CUST, "> cust")                                            || die 
"can't create cust: $_!";
open(OUTSTOCK, "> outstock.csv")                        || die "can't 
create outstock: $_!";
my %dopo;
while (<DOPO>) {
chomp;
s/,.*//;
$dopo{$_} = 1;
}
my %nostock;
while (<NOSTOCK>) {
chomp;
s/,.*//;
$nostock{$_}= 1;
}

while (<ORD>) {
my ($ponum) = (split(/,/))[2];
my ($item) = (split(/,/))[4];
select (CUST);
print  unless !$dopo{$ponum}|$nostock{$item}; # it prints just PO(s) from 
dopo list for the items not in nostock list, I need to remove the lines for 
which the sum of the seventh element for this same fourth element is >= 3
($custnum, $batchnum, $ponum, $store, $desc, $price, $qty, 
$pomonth,$poday,$poyear) = split(/,/, $_);
select (OUTSTOCK);
print "$ponum, $store, $desc, $price, $qty, $pomonth/$poday/$poyear" if 
$nostock{$item};
}

To get the lines for which the sum of the seventh element for this same 
fourth element is >= 3 (along with other things) I was trying this:
while ($line = <CUSTORD4>) {
         push @LoL, [ split ',', $line ];
}
$equal = "1";
$unequal = "00000001";
$count = "00000001";
$count1 = "1";
for $i ( 0 .. $#LoL ) {

         $aref = $LoL[$i];
         $bref = $LoL[$i+1];
         $n = @$aref - 1;
         $comp1 = $aref->[2] cmp $bref->[2];                     # it 
compares PO numbers
         $comp2 = $aref->[3] cmp $bref->[3];                     # it 
compares store numbers
         $comp3 = $aref->[1] cmp $bref->[1];                     # it 
compares batch numbers
         select (CUSTORD5);
         print 
"$equal,$unequal,$aref->[0],$aref->[1],$aref->[2],$aref->[3],$aref->[4],$aref->[5],$aref->[6],$aref->[7],$aref->[8],$aref->[9]";
         $equal = "1" if $comp2 ne 0;
         $equal++ if $comp2 eq 0;
         $unequal = "00000000" if $comp1 ne 0;
         $unequal++ if $comp2 ne 0;
         ############## just the test:
         $totqty = $totqty + $aref->[6];
         select (STDOUT);
         print 
"$count,$totqty,$aref->[6],$aref->[0],$aref->[1],$aref->[2],$aref->[3],$aref->[7],$aref->[8],$aref->[9]";#
 
can't use if $totqty ge 3, I need just the highest $totqty for each line 
with this same $aref->[3]
         $totqty = 0 if $comp2 ne 0;
         ##############
         select (CUSTORD6);
         print 
"$count,$aref->[0],$aref->[1],$aref->[2],$aref->[3],$aref->[7],$aref->[8],$aref->[9]" 
if $comp2 ne 0;
         select (ORDERS);
         print 
"$aref->[1],$aref->[0],$aref->[2],$count1,$aref->[7]/$aref->[8]/$aref->[9]" 
if $comp3 ne 0;
         $count = "00000001"  if $comp1 eq -1;
         $count1 = "1"  if $comp1 eq -1;
         $count++ if $comp2 eq -1;
         $count1++ if $comp2 eq -1;
}

Can you help me to find my way?
TIA.
Greg


---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to