# NOTE: I have already prepended pwd if needed #remove . while( $path =~ m#/\./# ) { $path =~ s#/\.#/#; } # remove .. while( $path =~ m#/[^/]+?/\.\./# ) { $path =~ s#/[^/]+?/\.\.#/#; } #### #remove . while ( $path =~ s#/\./#/# ) {;} #remove .. while ( $path =~ s#/[^/]+?/\.\./#/# ) {;} #### while ( $path =~ s#(/[^/]+)?/\.(\.)?/defined($2) ? "/" : "$1/"/e ) {;} #### unless ( chdir $path ) { die "Couldn't there ($path) from here\n"; } return `pwd`;