in reply to DBI question

$quoted_string = $dbh->quote($string);
You may want to see perldoc DBI.