I fixed your code for all cases except '/..' (which returns '.'):
sub remove_dot_dot_frodo72 { my $path = File::Spec::Unix->canonpath($_[0]); my @true; /^\.\./ && @true ? pop(@true) : push(@true, $_) # <- Added to cond foreach File::Spec::Unix->splitdir($path); $path = File::Spec::Unix->catdir(@true); return length($path) ? $path : '.'; # <- Added. }
In reply to Re^5: Cleaning up a path
by ikegami
in thread Cleaning up a path
by polettix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |