I'm having trouble trying to add some values. I have a data file that
consists of part numbers and quantities. I open that file, load the
data file into an array. My problem is that my data file has been
created by a process I cannot control, so that many times the
data file will show the same part number but with a different
quantity.
I need to add all of the quantities that are shown with the same
part number. Here is some sample code and the data file ...
Any help is appreciated,
~
#!/usr/bin/perl
print "Content-type: text/html\n\n";
open(INF,"expr3.dat") or print "Can't open expr3.dat: $!";
@partandqty = <INF>;
close(INF);
foreach $partandqty (@partandqty) {
($partnum,$qty) = split(/_/, $partandqty);
print "$partnum ** $qty<br>";
###### IF THE PARTNUM IS THE SAME - ADD THE QUANTITIES
OF THE SAME PARTNUM
###
}
+++
a8160_1234
a8161_5678
a8162_9876
a8163_4321
a8164_8765
a8165_3000
a8165_1800
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]