Perl Monk, Perl Meditation | |
PerlMonks |
Re: moving from mac to PC (updated!)by haukex (Archbishop) |
on Oct 28, 2016 at 07:41 UTC ( [id://1174875]=note: print w/replies, xml ) | Need Help?? |
Hi flieckster, For portable filename handling, I recommend the core module File::Spec, or from CPAN Path::Class:
I admit I haven't worked with volume specs in either module, Update 2016-10-29: I tested this on a Windows machine and apparently, in File::Spec, the volume argument to catpath needs to be 'C:', not just 'C', while in Path::Class, the volume needs to be specified as 'C:\\' for things to work properly (unfortunately it seems neither of these points are mentioned in the docs). I updated the above code accordingly and added some more output. The Path::Class code does not work the same under Linux as under Windows: since in Linux "C:\" is a valid name for a directory, that path component is treated like just another regular directory. Here are the outputs:
Hope this helps,
In Section
Seekers of Perl Wisdom
|
|