in reply to cleaning up absolute path without resolving symlinks

(untested)
sub Resolve { my @stack = $_[0] =~ /^\./ ? split /\/, $ENV{ PWD } : (); join '/', map { ( $_ eq '..' ) ? pop @stack : ( $_ ne '.' ) && ( push @stack, $_); } split /\/, $_[0]; }

-M

Free your mind

Replies are listed 'Best First'.
Re^2: cleaning up absolute path without resolving symlinks
by chromatic (Archbishop) on Mar 06, 2007 at 20:08 UTC

    Depending on how cross-platform you need to be, you might use updir() and related functions from File::Spec instead of ...