in reply to replacing "\L" character in strings

Try "forward slash": /. Perl is amazingly smart about path names under Windows and without any exceptions that I can think of, / works better than \ for paths that Perl knows about.
  • Comment on Re: replacing "\L" character in strings

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

    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?

      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.
      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 '\\'.
      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.
Re^2: replacing "\L" character in strings
by ikegami (Patriarch) on Jul 26, 2010 at 16:12 UTC
    Actually, Perl is incredibly dumb about path names, passing the path unchanged to Windows. Windows accepts both "/" and "\" as path separators.