Trying to get Path::Class to pass it's tests on VMS Perl 5.8.7 on
ODS-2 disk.

One of the test cases is calling:

  File::Spec->splitpath('t',1);

So on Unix:

perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',0))"
||t

perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',1))"
|t|

On VMS:

perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',0))"
||t

perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',1))"
||t

It's this last command that is the problem, the expected behaviour in
Path::Class is |t|.

The doc for File::Spec->splitpath states:

splitpath

    Splits a path in to volume, directory, and filename portions. On
systems with no concept of volume, returns '' for volume.

        ($volume,$directories,$file) = File::Spec->splitpath( $path );
        ($volume,$directories,$file) = File::Spec->splitpath( $path,
$no_file );

    For systems with no syntax differentiating filenames from
directories, assumes that the last file is a path unless $no_file is
true or a trailing separator or /. or /.. is present. On Unix, this
means that $no_file true makes this return ( '', $path, '' ).

    The directory portion may or may not be returned with a trailing
'/'.

    The results can be passed to "catpath()" to get back a path
equivalent to (usually identical to) the original path.


So I'm wondering if File::Spec::VMS->splitpath should support $no_file
or not?  It looks like the majority of File::Spec::* modules do, I
don't know if they all have syntax that does not differentiate
filenames from directories.

Current File::Spec::VMS splitpath is:

sub splitpath {
    my($self,$path) = @_;
    my($dev,$dir,$file) = ('','','');

    vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s;
    return ($1 || '',$2 || '',$3);
}

This hack changes the behaviour so that File::Spec::VMS->splitpath('t',
1) returns t as the dir and not the file.  All PathTools 3.27 tests
still pass.

sub splitpath {
    my($self,$path, $nofile) = @_;
    my($dev,$dir,$file) = ('','','');
    if ( $nofile ){
        vmsify($path) =~ /(.+:)?(.*)/s;
        return ($1 || '',$2 || '',$file);
    }
    else {
        vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s;
        return ($1 || '',$2 || '',$3);
    }
}

Just wondering if anyone has any thoughts on this?

Thanks,

Peter (Stig) Edwards

Reply via email to