in reply to Re^2: Working directory oddity
in thread Working directory oddity

Using the same path you provided avoids confusion. Unix usually does the same thing. If you use /home/ikegami/symlink/dir, it won't magically become /some/where/else/dir.

File::Spec definitely won't help, since it doesn't do any system calls.

You could always do a directory listing for every component of the path and look for the matching name. That can fail due to permissions and if one of the components is an 8.3 name, but you can always fall back to what you were provided for those components.

Finally, so what if you have to branch. You're asking to do something platform-specific, after all. Just hide it in a module with a thin, portable interface. It can call Win32::GetLongPathName on Windows and File::Spec->canonpath on other platforms.

Replies are listed 'Best First'.
Re^4: Working directory oddity
by sg (Pilgrim) on Oct 19, 2007 at 15:07 UTC

    I was using File::Spec with Cwd. Isn't the purpose of Cwd, especially its realpath, to be "the hiding module" suggested above?

      Yes, that does sounds like a good place for it. You could submit a patch to add this function to Cwd.

        Good point. I wasn't sure if I was not using Cwd properly or if what I was seeing was a shortcoming with Cwd.