use Path::Class qw(dir); print dir('/foo/../dir/')->cleanup;