in reply to DBI question

The suggestion above about the DBI quote method is your best bet in this specific case. In general, you are better off using the q{} and qq{} generic quote operators, as opposed to backwhacking internal quotes. (Note that you can use almost any character for the delimiters, not just {}; perldoc perlop for full details.)

For example: q{"Sue said 'Go away'", Sarah told me}.

Replies are listed 'Best First'.
Re^2: DBI question
by crashtest (Curate) on Mar 10, 2005 at 23:36 UTC
    I think the OPs problem was not escaping text within a Perl string, but escaping text within a SQL statement. In general, you double up your quotes for that, i.e. to insert the string "Sue's Sister" into a database, you would write...
    INSERT INTO sometable VALUES ('Sue''s Sister')
    ... although the $dbh->quote method is cleaner if you're working with Perl.

      Yep. That's why I said "...is better in this specific case. In general...."

      :>
      It was a problem with SQL and not a perl problem. Doubling up the single quotes solved the problem.
      Thanks for you help
        SO, in other words, you completely ignored our advice. DO NOT HANDLE QUOTING YOURSELF. You are certain to get into trouble eventually either through SQL injection attack or through missing something that should have been escaped. Use placeholders.