in reply to Re: FTP Problems
in thread FTP Problems

Um, please try your first suggestion youself. ;) \ is still special inside of single quotes and will escape the trailing delimiter, just like it did in the original code. Yes, if the \ is not followed by another \ or your string delimiter (or either of your string delimiters if using nesting delimiters as in q{}), then the \ will be preserved within single quotes. I discourage that because I feel that it leads to mistakes when the \ is followed by one of these characters. If someone as sharp as Fastolfe can get snagged by this, then I think my paranoia is justified. (:

I always double backslashes when I want a backslash unless I'm in a "here doc".

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: \ in single quotes (Re: FTP Problems)
by Fastolfe (Vicar) on Jan 26, 2001 at 22:40 UTC
    Well, if I were doing this in my own application, I would have tested my solution first and realized the mistake. You're right, though. Heh.

    If you ask me, I hate the fact that back-slashes are special at all within single-quoted strings, precisely for this problem. People make the assumption that single-quotes mean no interpolation is done, that they are safe putting whatever they want in the string. Backslashes are essentially ignored/safe except in the case of a second backslash or a single-quote itself. I might argue that backslashes be totally ignored/unspecial in a single-quoted string. Injecting single quotes might be done by doubling them up.

      Yes, the trailing delimiter being escaped usually becomes obvious quickly. Trying to access a shared disk via '\\host\share\dir\file.ext' can be very hard to debug and can cause you to waste a lot of time.

              - tye (but my friends call me "Tye")