or download this
$path='./anything/../.../something'; #example
$path=~s!/+!/!g; #replace //// by single /
...
$path=~s!^([^/]{3,}|[^/.][^/]*|\.[^/.])/\.\./!!; #remove starting som
+ething/../
$path='.' if $path eq ''; #point current path if finally it is empty
#at this place $path is normalized