"Yannick Warnier" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hi all,
> I'm trying to use the canonpath() method of the File::Spec module, but
> it seems I don't get the goal of that method...
>
> What I'm trying to do is:
>  I have a path ("/home/user1/dir/..") and want to make it right (so in
> this case, "/home/user1").
>
> How can I do that without playing with some splitdir() or things like
> that?

Your problem is that 'dir' may be a link instead of a real beastie
(in which case /home/user1/dir/.. may be somewhere other than
/home/user1) so all canonpath will do is to remove successive
/// and /././. strings from the text. As long as the path actually
exists on the file system, you can do this

  use Cwd 'abs_path';
  print abs_path '/home/user1/dir/..';

OUTPUT (normally)

  /home/user1


I hope this helps.

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to