$sth = $dbh->prepare (qq{ SELECT * FROM mytable WHERE some_column = ? }); # The ? is a placeholder $sth->execute($str); # $str is what your searching for $row = $sth->fetchrow_hashref(); # This executes the above $sth->finish();# This closes the connection.