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")
| [reply] |
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.
| [reply] |
| [reply] |
Just out of curiosity, why not simply use forwardslashes instead? I use them consistently in win32 applications with no issue. Am I missing something? | [reply] |
No, you're not. They'll work fine in most any case.
| [reply] |