Hi flieckster,

For portable filename handling, I recommend the core module File::Spec, or from CPAN Path::Class:

use Data::Dumper; $Data::Dumper::Useqq=1; $Data::Dumper::Terse=1; use File::Spec::Functions qw/catdir catpath/; print Dumper( catdir('','photorepos','Perl','Mother','WorkLoad') ); # the following volume spec is ignored in *NIX print Dumper( catpath('C:', catdir('','photorepos','Perl','Mother','WorkLoad')) ); use Path::Class qw/file dir/; print Dumper( dir('C:\\')->subdir('photorepos')->subdir('Perl') ->subdir('Mother')->subdir('WorkLoad').'' ); my $dir = dir('C:\\','photorepos','Perl','Mother','WorkLoad'); print "Path: ", Dumper( "$dir" ); print $dir->is_absolute ? "Is Absolute\n" : "Is Relative\n"; print "Volume: ", $dir->volume, "\n"; print "Dir List: ",Dumper( [$dir->dir_list] );

I admit I haven't worked with volume specs in either module, and I don't have a Windows machine handy at this moment, so the above may need some tweaking in that respect.

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:

# Windows "\\photorepos\\Perl\\Mother\\WorkLoad" "C:\\photorepos\\Perl\\Mother\\WorkLoad" "C:\\photorepos\\Perl\\Mother\\WorkLoad" Path: "C:\\photorepos\\Perl\\Mother\\WorkLoad" Is Absolute Volume: C: Dir List: ["", "photorepos", "Perl", "Mother", "WorkLoad"] # Linux "/photorepos/Perl/Mother/WorkLoad" "/photorepos/Perl/Mother/WorkLoad" "C:\\/photorepos/Perl/Mother/WorkLoad" Path: "C:\\/photorepos/Perl/Mother/WorkLoad" Is Relative Volume: Dir List: ["C:\\", "photorepos", "Perl", "Mother", "WorkLoad"]

Hope this helps,
-- Hauke D


In reply to Re: moving from mac to PC (updated!) by haukex
in thread moving from mac to PC by flieckster

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.