in reply to Re^2: CPAN Module for mixing Unix/Windows path
in thread CPAN Module for mixing Unix/Windows path

I don't quite understand the problem.

From the OP: Internally, I use / as a separator whenever possible. For path strings I get from the "outside", I use File::Spec to be OS independent.

Do any paths come from somewhere else, that you can't keep track of and normalize? My point is that Path::Class, just as File::Spec which it uses internally, expects Unix style paths when run on Unix, and Windows style paths when run on Windows, unless you tell it otherwise. So for new never-before-seen paths you do

my $path = dir($from_outside)->as_foreign('Unix');
and once they're internal, you just do
my $path = foreign_dir('Unix', $internal);
Is this unapplicable to your problem?

lodin

Replies are listed 'Best First'.
Re^4: CPAN Module for mixing Unix/Windows path
by rovf (Priest) on Jun 06, 2008 at 08:52 UTC

    It is partiallly applicable. For nearly all pathes coming from the outside, I don't know whether they are Unix or Windows style. They might even be mixed, such as a/b\c\d/e. This is possible since we have the requirement (actually a very common requirement in mixed language projects), that certain characters are forbidden in directory/filenames. For example, no '\', no '@' etc.

    As said before, this is not difficult to implement, but I was thinking that maybe someone has already published utilities I could re-use. In practice, I have to normalize the path name before the first use, by (at least) converting the backslashes to forward slashes, but being careful with things like double backslash etc.

    -- 
    Ronald Fischer <ynnor@mm.st>