While doing some porting I noticed this inconsistency between Unix and VMS with catdir.
VMS> perl -e "use File::Spec::Functions; print catdir("""",'a','b');
[.a.b]
VMS> perl -e "use File::Spec::Functions; print catdir("" "",'a','b');
a:[b]I'd expect to get an absolute path in both cases. In fact, only the first should give a correct answer. On Unix it behaves as I expect:
unix> perl -e "use File::Spec::Functions; print catdir('','a','b');"'print "\n";'
/a/b
unix> perl -e "use File::Spec::Functions; print catdir(' ','a','b');"'print "\n";'
/a/b
This is with perl 5.8.2 and the File::Spec that comes with it.
This problem prevents me to do this:
catdir( split('/','/some/absolute/path') );
Or more to the point, how do you do this in a portable way:
$r = '/root'; $y = $r . '/subdir/subsubdir'; $z = $r . '/subdir1';
My idea doesn't work:
use File::Spec::Functions;
$r = catdir( split('/','/root') );
$y = catdir( $r, split('/','/subdir/subsubdir') );
$z = catdir( $r, split('/','/subdir1') );print "\$r: $r\n\$y: $y\n\$z: $z";
That gives
$r: [.root] $y: [.root.subdir.subsubdir] $z: [.root.subdir1]
What I want is of course
$r: root:[000000] $y: root:[subdir.subsubdir] $z: root:[subdir1]
Any ideas?
Thanks, Michael
