Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

File::Spec bug on VMS

by swkronenfeld (Hermit)
on Sep 28, 2006 at 18:35 UTC ( #575396=perlquestion: print w/replies, xml ) Need Help??

swkronenfeld has asked for the wisdom of the Perl Monks concerning the following question:

There is some strange behavior on File::Spec->catfile on VMS (perl, v5.8.1 built for VMS_AXP)

Whenever my path length is a multiple of 8 + 1 (or a multiple of 8+3 if you count the brackets), e.g. 9, 17, 23, the path is formed incorrectly (as shown below). It discards the second argument and forms a file path based on the first argument only.
my $path = "[DIR."; my $tmp = ""; for(my $x=0; $x<60; $x++) { $tmp .= "a"; my $tmp2 = $path . $tmp . "]"; print File::Spec->catfile($tmp2, "file") . "\n"; } ----------------------------- $ perl USERS:[DIR.a]file USERS:[DIR.aa]file USERS:[]file USERS:[DIR.aaaa]file USERS:[DIR]aaaaa USERS:[DIR.aaaaaa]file USERS:[DIR.aaaaaaa]file USERS:[DIR.aaaaaaaa]file USERS:[DIR.aaaaaaaaa]file USERS:[DIR.aaaaaaaaaa]file USERS:[DIR.aaaaaaaaaaa]file USERS:[DIR.aaaaaaaaaaaa]file USERS:[DIR]aaaaaaaaaaaaa USERS:[DIR.aaaaaaaaaaaaaa]file USERS:[DIR.aaaaaaaaaaaaaaa]file USERS:[DIR.aaaaaaaaaaaaaaaa]file
I haven't been able to find anything through SuperSearch, google, cpan, etc related to this "bug". Does anyone have any idea what's going on? The next step will be to step through the Spec::File code, likely somewhere in the vmsify function or a child of it since this does not happen on UNIX.

Also, I have the latest version of File::Spec and File::Spec::VMS.

Any thoughts?

Replies are listed 'Best First'.
Re: File::Spec bug on VMS
by swkronenfeld (Hermit) on Sep 29, 2006 at 15:37 UTC
    So, after too much time stepping through with the debugger...

    There is a bug in the function unixify (in VMS::Filespec). A control character is added to the end of certain length paths:
    47: my($npath) = unixify($path); DB<7> x $path 0 '[DIR.aaaaa]' DB<8> s File::Spec::VMS::eliminate_macros(/perl_root/lib/File/Spec/ 48: my($complex) = 0; DB<8> x $npath 0 "/USERS/DIR/aaaaa\c@" # <---- What's that \c@ doing there?!
    As opposed to
    47: my($npath) = unixify($path); DB<9> x $path 0 '[DIR.aaaaaaa]' DB<10> s File::Spec::VMS::eliminate_macros(/perl_root/lib/File/Spec/ 48: my($complex) = 0; DB<10> x $npath 0 '/USERS/DIR/aaaaaaa/'

    I don't know how to solve this, but as a workaround, if you always pass the device name to the catfile function, it works. So do this:
    print File::Spec->catfile("USERS:[DIR.aaaaa]", "file"); # Include USER +S:, or else this won't work!

      Thanks for finding this and narrowing it down. Please report it to (or by going to the distribution that contains VMS::Filespec and following the "View/Report Bugs" link).

      - tye        

Re: File::Spec bug on VMS
by syphilis (Archbishop) on Sep 29, 2006 at 09:30 UTC
    Hi swkronenfeld,

    I see that File::Spec::VMS loads both File::Basename and VMS::Filespec - so it's at least conceivable that the bug arises from code in one of those 2 modules (the latter being more lkely than the former, I would guess).

    There's a couple of if/else branches in the catfile() sub in File::Spec::VMS. I'd probably start with some debug print() statements inside that sub to determine just which route is being followed and trace it back from there ... if I had access to a VMS system: -:)


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://575396]
Approved by Tanktalus
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2023-01-31 22:28 GMT
Find Nodes?
    Voting Booth?

    No recent polls found