Subject: | [PATCH] make File::Spec::VMS::splitdir return empty array on empty or undefined input |
Hmm. Looks like I just missed a release by a few days. This was reported on vmsperl some
time ago and I've finally gotten around to doing something about it. When splitdir is passed an
empty string or undef, it returns an empty scalar on VMS, as opposed to an empty array on all
other platforms. It seems like we ought to do what everybody else does. The attached patch
gets us in sync.
Subject: | splitdir_undef_return.patch.txt |
--- lib/File/Spec/VMS.pm;-0 Tue Jun 13 14:29:14 2006
+++ lib/File/Spec/VMS.pm Mon May 28 17:08:49 2007
@@ -260,6 +260,8 @@ Split dirspec using VMS syntax.
sub splitdir {
my($self,$dirspec) = @_;
+ my @dirs = ();
+ return @dirs if ( (!defined $dirspec) || ('' eq $dirspec) );
$dirspec =~ tr/<>/[]/; # < and > ==> [ and ]
$dirspec =~ s/\]\[\./\.\]\[/g; # ][. ==> .][
$dirspec =~ s/\[000000\.\]\[/\[/g; # [000000.][ ==> [
@@ -274,7 +276,7 @@ sub splitdir {
# .--] ==> .-.-]
# [--] ==> [-.-]
$dirspec = "[$dirspec]" unless $dirspec =~ /[\[<]/; # make legal
- my(@dirs) = split('\.', vmspath($dirspec));
+ @dirs = split('\.', vmspath($dirspec));
$dirs[0] =~ s/^[\[<]//s; $dirs[-1] =~ s/[\]>]\Z(?!\n)//s;
@dirs;
}