Path::Trim currently does not have any ties with the filesystem. That is, it does not check if the path is valid in the system in which trim_path is executed. Hence, it can trim any path on any system (I hope). For example: a path with \ as separator on Linux.
Cwd's abs_path() requires that the path be valid in the system in which it is executed. Since Path::Trim does not check the filesystem, it is different and can trim paths that are not present or are invalid.
Most probably, next version of the module will have the feature that you have suggested.
__Path::Trim is different from File::Path::Collapse__
Path::Trim allows for the setting of directory separator, current directory and parent directory, thus being able to trim any kind of path. The following are preserved:
* trailing directory separator ( Example: a/b/../ => a/ ) (which may be removed in a new release)
* single current directory ( Example: . => . )
* single parent directory ( Example: .. => .. )
0 out of 1 found this review helpful. Was this review helpful to you? Yes No
I believe this does the same thing:
1 out of 1 found this review helpful. Was this review helpful to you? Yes No
It's worse than that.
First, you have to manually set the directory separator. Why does the module not just ask the system?
Second, it breaks badly on symbolic links:
% ln -s /etc /tmp/test
% perl -MPath::Trim -E '$t = Path::Trim->new(); $t->set_directory_separator("/"); say $t->trim_path("/tmp/test/..");'
% perl -MCwd=abs_path -E 'say abs_path("/tmp/test/..")'
2 out of 2 found this review helpful. Was this review helpful to you? Yes No