I actually doubt that there is a Perl platform where '/' isn't as good a choice as anything. There are certainly systems out there that can run Perl that don't have "a directory separator". But, in Perl, '/' often works as a directory separator in at least some cases on even those platforms. Similarly, '/' works as a directory separator in most places in Perl even on platforms that have "a directory separator" that isn't (just) '/'.
I believe that "use Foo::Bar;" sets $INC{'Foo/Bar.pm'} on every Perl platform, even ones with no "directory separator" and ones with a non-'/' primary directory separator.
In particular, I bet rsync understands '/' even when run under Windows (as most things in Windows do as well). (It does for me, but my rsync on Windows is part of cygwin.)
"Append a trailing directory separator" just isn't a portable concept. That's why the portable path manipulation modules don't support it. So doing portable path manipulation portably is a good idea. Appending a trailing directory separator in Perl for rsync might as well just be .= '/';.
The somewhat portable concept is "give me a directory path (not a file path)". That is why File::Spec::Unix (etc.) has catdir() separate from catfile(). Sadly, File::Spec::Unix::catdir('foo','bar') returns "foo/bar" not "foo/bar/". You might consider filing a bug against that. I have no idea if those who would be notified of such a bug report would have any sympathy toward our point of view on that, however.
- tye
In reply to Re: Directory Separator (none)
by tye
in thread Directory Separator
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |