Under all the versions of Perl on VMS I have available, including 5.8.7
using the latest PathTools 3:24 all of the following print 1.
perl -e "use File::Spec;print scalar(File::Spec->splitdir(''))"
perl -e "use File::Spec;print scalar(File::Spec->splitdir())"
perl -e "use File::Spec;print scalar(File::Spec->splitdir(undef))"
The single element is an empty scalar.
I'm thinking I should be getting a 0 back, an empty array. (I get 0
back from Win, Cygwin and Linux, I don't have access to a Mac, but I
suspect from looking at the code it will explicitly return the same as
VMS does?)
Is this a bug (in VMS.pm) or might this be desired behaviour?
>From the docs:
>> Unlike just splitting the directories on the separator, empty
>> directory names (C<''>) can be returned, because these are significant
>> on some OSes.
If it's a bug then this edit works for me, and all the unit tests still
pass.
PathTools-3_24/lib/File/Spec/VMS.pm
******
263 $dirspec =~ tr/<>/[]/; # < and >
==> [ and ]
******
263 return () if ( (!defined $dirspec) || ('' eq $dirspec) );
264 $dirspec =~ tr/<>/[]/; # < and >
==> [ and ]
******
I couldn't fit a test for this into the spec.t file in an elegant way,
so here is a quick edit to test this:
PathTools-3_24/t/spec.t
******
626
627
628 plan tests => scalar @tests;
629
******
626 plan tests => 1 + scalar @tests;
627
628 my @got = File::Spec::VMS->splitdir('');
629 my $got = scalar @got;
630 ok $got, 0, "scalar(File::Spec::VMS->splitdir(''))";
631
******
Thanks for your thoughts,
Peter (Stig) Edwards