in reply to Re: Cleaning up a path
in thread Cleaning up a path

1while s#[^/]+/..(/|$)##
ikegami's remarks still apply.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re: (golf): Cleaning up a path
by ikegami (Patriarch) on Apr 13, 2005 at 18:39 UTC

    aye, works great (if you canonise first)

    sub remove_dot_dot_roy_edited { local $_ = $_[0]; $_ = File::Spec::Unix->canonpath($_); 1while s#[^/]+/..(/|$)##; return length($_) ? $_ : '.'; }