in reply to Collapsing paths

if you are interested in doing it with regexp:
{ $path =~ s{(^|/)(\w+/\.\./|\./)}{$1} and redo }
which collapses ./ and <dir>/../

Oha

Replies are listed 'Best First'.
Re^2: Collapsing paths
by ikegami (Patriarch) on Dec 05, 2007 at 21:53 UTC

    It wouldn't hurt to make the loop more obvious.

    1 while $path =~ s{(^|/)(\w+/\.\./|\./)}{$1};

    It's even shorter.