in reply to FTP Problems

Your problem probably stems from the fact that you are using backslashes (\) in your interpolated (double-quoted) string in your $path assignment. Either use single-quotes or escape your backslashes by doubling them. Your last quotation mark is being interpreted as a literal quotation mark in the string, which is totally screwing up your next few lines of code, because Perl is treating it all as part of the same string.

Replies are listed 'Best First'.
\ in single quotes (Re: FTP Problems)
by tye (Sage) on Jan 26, 2001 at 22:39 UTC

    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")
      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")
Re: Re: FTP Problems
by the_slycer (Chaplain) on Jan 26, 2001 at 23:37 UTC
    Just out of curiosity, why not simply use forwardslashes instead? I use them consistently in win32 applications with no issue. Am I missing something?
      No, you're not. They'll work fine in most any case.