in reply to Re: replacing "\L" character in strings
in thread replacing "\L" character in strings

Thanks ww and Marshall, sorry if I was not clear, but what is passed here is not path names but database server names and the server names have a backslash inside it. and if the letter coming after the backslash is a recognised escape character, it escapes it.

Ex: if someone passes the server name as "SERVER05\LDEV", it is changed to "SERVER05dev" because \L is taken as 'convert all characters to lower case till a \E is found. Since the server name is different, the connection fails

is there a way to ignore escape characters in strings or some other way?

  • Comment on Re^2: replacing "\L" character in strings

Replies are listed 'Best First'.
Re^3: replacing "\L" character in strings
by Corion (Patriarch) on Jul 25, 2010 at 18:25 UTC

    As you don't show any code, it's hard to tell you what you really mean. Maybe you want to use quotemeta respectively \Q in your regular expression, to prevent interpolation of regex-meta-characters? See perlre and/or perlop.

      Thanks a lot Corion. I used the quotemeta function to escape the metacharacters. this is working fine for me.
Re^3: replacing "\L" character in strings
by Marshall (Canon) on Jul 25, 2010 at 18:33 UTC
    The normal way to put a "backslash" in a character stream is to "back slash" the "backslash", i.e. with '\\', the first back slash means that the next char (which is a backslash) should be taken literally. In other words, convert single '\' to '\\'.
Re^3: replacing "\L" character in strings
by ww (Archbishop) on Jul 25, 2010 at 20:03 UTC
    Lacking any hint of how you've code the script, it's hard to be confident that my first suggestion -- that you use NON-INTERPOLATING SINGLE QUOTES (') -- will solve your problem... but it might, as might Corion's re quotemeta.