Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^3: CPAN Module for mixing Unix/Windows path

by lodin (Hermit)
on Jun 05, 2008 at 18:01 UTC ( #690488=note: print w/replies, xml ) Need Help??

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?


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 <>

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2022-01-27 21:15 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (71 votes). Check out past polls.