Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Issue with env variables set through dos batch

by ikegami (Patriarch)
on Oct 13, 2011 at 16:48 UTC ( [id://931316]=note: print w/replies, xml ) Need Help??


in reply to Re: Issue with env variables set through dos batch
in thread Issue with env variables set through dos batch

In almost all cases, forward slash, '/' works like '\'.

That's pushing it. It's true in Perl (since the Windows API accepts "/"), but not so much in the shell (because "/" is the command line option starter, and it doesn't need to be preceded by whitespace). For example, dir /users won't work.

That said, if you place the path in quotes, "/" is much more likely to get accepted. For example, dir "/users" does work.

This is only relevant if $pathSeparator is used to build shell commands, which is possible. It's hard to tell, since $pathSeparator isn't actually used in the posted snippet.

Replies are listed 'Best First'.
Re^3: Issue with env variables set through dos batch
by Marshall (Canon) on Oct 15, 2011 at 16:47 UTC
    Yes, there are issues with \ vs / in Windows. I think that there are things like '\' is needed on a path to an .exe.

    In Perl code, using "/" in a Perl function almost always or at least I don't know of a case where it does not. But YES, there are cases where Windows itself is pretty finicky about this. Yes, I would quote a path, like "/file", because there are even more lexical pitfalls like "divided" by file!

    Without spending hours thinking about it, I cannot cover every single case. My method is simplistic, I write something that "feels right" and if it is wrong, I try again and then verify that the new formulation is "right". It just seems like when I think I've learned everything about it, I get bit with a new wrinkle when dealing with this \ and / Windows command line stuff! I think that is just the nature of the beast.

    Anyway, I post my code and learn things. Thanks!

      >/progs/perl5140-ap1400/bin/perl -E"say 'ok'" ok

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-29 13:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found