canonpath in File::Spec seems to do the trick.
use File::Spec::Functions 'canonpath'; print canonpath('foo/../bar/../baz/'); __END__ baz
lodin
Update: added examplifying code, but see ikegami's reply below.
In reply to Re: Collapsing paths
by lodin
in thread Collapsing paths
by rvosa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |