#!/usr/bin/perl -w use strict; my $path = "/foo/mik/../mik/./../mik"; # print "Path is --$path--\n"; $path =~ s!/\.([^.])!$1!g; # print "Path is now --$path--\n"; while ($path =~ m!/\.!) { $path =~ s!/[^\/]+/\.\.!!; # print "Path is now -+$path+-\n"; } print "Ended up with =>>$path<<=\n";