On Sun, Nov 16, 2003 at 01:06:26AM +0100, Michael Lemke wrote:
> 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]

Check your quoting.  You've got the program surrounded by double quotes
and you're using double quotes inside.  Did you, perhaps, mean...

perl -e "use File::Spec::Functions;  print catdir('""','a','b');
perl -e "use File::Spec::Functions;  print catdir('" "','a','b');


> 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?

catdir() doesn't take volumes, just directories.  It shouldn't
interpret any of the arguments to be volumes.  You won't get what you
want from catdir.  What you want is catpath() maybe?


-- 
Michael G Schwern        [EMAIL PROTECTED]  http://www.pobox.com/~schwern/
Here's hoping you don't harbor a death wish!

Reply via email to