in reply to File::Spec::Win32::catfile behaviour for empty path components

I found out today, that catfile('') results in a nullstring on Perl 5.7 and Perl 5.10, but returns \ on Perl 5.8.8

I get the same as your for perl-5.8.8, but for perl-5.10.0 I get:
C:\>perl -MFile::Spec -e "print File::Spec::Win32::catfile('')" Can't call method "canonpath" without a package or object reference at + C:/_32/ap1004/lib/File/Spec/Win32.pm line 130. C:\>
Given that the catdir documentation specifies "Concatenate two or more directory names...", and that I failed to provide "two or more directory names" as arguments, I think it's reasonable that I got an error - though perhaps it would be clearer if catdir were to count the arguments received, and then reject my code on the basis of "insufficient arguments".

Cheers,
Rob

Update: Yep, if I call catfile as a method on 5.10.0 then I get the same as the OP.

Replies are listed 'Best First'.
Re^2: File::Spec::Win32::catfile behaviour for empty path components
by ikegami (Patriarch) on Nov 05, 2008 at 10:20 UTC

    That error you are getting is unrelated to the topic brought up by the OP. catfile should be called as a method:

    >perl580\bin\perl -MFile::Spec -le"print File::Spec::Win32->catfile('' +)" >perl588\bin\perl -MFile::Spec -le"print File::Spec::Win32->catfile('' +)" \ >perl5100\bin\perl -MFile::Spec -le"print File::Spec::Win32->catfile(' +')" >

    But I agree with your analysis. In short, GIGO.

Re^2: File::Spec::Win32::catfile behaviour for empty path components
by rovf (Priest) on Nov 05, 2008 at 11:43 UTC

    You did not call catfile in the right way. If you don't drag it in via File::Spec::Functions, you need to call it like this:

    c:\perl\bin\perl -MFile::Spec -e "print File::Spec::Win32->catfile('') +"
    which prints the empty string (in Perl 5.10 and in Perl 5.7).

    -- 
    Ronald Fischer <ynnor@mm.st>