if ($what eq "W") { $sth = $dbh->prepare( sprintf "select * from %s where %s = %s",$dbh->quote_identifier($table),$dbh->quote_identifier($col),$sel); .....and so on } }