Apr 10, 2000, 2:55 PM
Post #2 of 2
The most efficient way to calculate subtotals is by incrementing the subtotal at the same time you are looping through your products to display. For example:
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>
my ($name,$price,$etc)= split(/|/,$_);
print "Name: $name<BR>";
print "Price: $price<BR>";
print "Your subtotal is $subtotal";
The += increments subtotal by price through each iteration of the loop.
Hope this helps!