in reply to quotemeta and \% to insert perl code into database

You shouldn't quotemeta already quotemeta-ed strings. There is no reasonable way for quotemeta to be able to tell what has been quotemeta-ed before, and what just needs a backslash before the special characters because you put it there.

Data going back-and-forth should be marked somehow, so that you are able to tell that quoting has already been done.

You can write your own routine that won't escape backslashes that are in front of characters that need escaping, but I predict sooner or later you will run accross a string where the backslash came in the input, and not as the result of quoting.

Replies are listed 'Best First'.
Re: Re: quotemeta %
by macPerl (Beadle) on Mar 12, 2004 at 14:24 UTC
    Matija,

    as per my response to Abigail, I guess I didn't include enough info (sorry). The DBI stores the info UN-quotemeta'ed(!). So the next retrieval displays as it was originally.

    I tested this for all characters from chr(34) to chr(255) and the only one that doesn't get UN-quotemeta'ed is the % Symbol.


    Actually I've just realised (duh) that the issue is not with "quotemeta" at all, but the DBI which strips all other escapes out but the one preceding the %.

    Anyway, thanks for your help.