$where  = "WHERE articleNr='".xChop($values{ARTICLENR})."'"; $cmd    = "SELECT instock, vendor, price FROM prices $where"; $xret   = $dbconn->prepare($cmd); $xret->execute || $log->debug("$cmd -- could not get items in stock. SQL Error:$DBI::errstr"); $winner = 9999999; while(@array = $xret->fetchrow_array) { if(@array[0] eq "1") { $vendor = xChop(@array[1]); $cmd     = "SELECT shippingCost FROM vendors "; $cmd    .="WHERE name='$vendor'"; $lret    = $dbconn->prepare($cmd); $lret->execute || $log->debug("could not get shipping cost. SQL Error:$DBI::errstr"); if(@ldat = $lret->fetchrow_array) { $sh     = @ldat[0]; } else { $sh     = 0.0; } $price = @array[2] + $sh; if($price > 0 && $price < $winner) { $winner = $price; $winnm  = $vendor; } } } unless ($winnm) { "0.00 sorry, no price"; } else { sprintf("%.2f $winnm", $winner); } 