in reply to Changing foreach loop for a while loop

Just a thought, depending on what else is in the block. You may want to prepare your SQL statement, with placeholders, outside the loop
my $sql = "SELECT C58XX.CCLMyy, C58XX.CLINyy FROM C58XX WHERE C58XX.CCLMyy=? AND C58XX.CLINyy=$X_LINE"; my $sth = $dbh->prepare($sql); while (@array) { $sth->execute($_); .... }