On this face of it, this is a real newbie question that I'm kind of embarrased to ask but here goes anyway ...
Given an absolute pathname as a base (say: /usr/local/src) and a relative path (say: ../bin/fnurgle) what module will give the 'canonical' absolute pathname: /usr/local/bin/fnurgle?
I thought this was one of the functions of the File::Spec module but this code ...
perl -MFile::Spec -le 'print File::Spec->rel2abs("../bin/fnurgle", "/usr/local/src")'... gives this ...
/usr/local/src/../bin/fnurgle... and so does this ...
perl -MFile::Spec -le 'print File::Spec->canonpath(File::Spec->rel2abs("../bin/fnurgle", "/usr/local/src"))'I can achieve the desired effect using a regex or even prepending 'file:' and using the URI module but shouldn't this be the default behaviour of File::Spec->canonpath()?
In reply to Absolute pathnames from relative? by grantm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |