sub RATIOCALC { our ($mOrv, @ratio, @density, @concentration, %chemname, @wtPercent, $statustext, @wtpercentbox); my (@wtPureAmt, @residualDI); if (defined($mOrv)){ $statustext = "Calculating..."; if ($mOrv eq "V"){ for (my $i = 0; $i <= $#ratio; $i++){ $ratio[$i] = $ratio[$i] * $density[$i]; $mOrv = "M"; }; }; for (my $j = 0; $j <= $#ratio; $j++){ $wtPureAmt[$j] = $ratio[$j] * $concentration[$j]; }; for (my $k = 0; $k <= $#ratio; $k++){ $residualDI[$k] = $ratio[$k] * (1 - $concentration[$k]); }; my $totalmass = sum(@ratio); my $diIndex = $chemname{'DI'}; if ($totalmass != 0){@wtPercent = map{$_ / $totalmass}@wtPureAmt}else{$statustext = "You need to give me numbers!"}; if ($wtPureAmt[$diIndex] == 0) { $wtPercent[$diIndex] = sum(@residualDI) / $totalmass; } else { $wtPercent[$diIndex] = (sum(@residualDI) + $wtPureAmt[$diIndex]) / $totalmass; } $statustext = "(@wtPercent)"; }else{ $statustext = "You need to select weight or volume ratio!" };