Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: windows perl and paths

by eyepopslikeamosquito (Archbishop)
on Nov 20, 2016 at 05:37 UTC ( [id://1176185]=note: print w/replies, xml ) Need Help??


in reply to Re^3: windows perl and paths
in thread windows perl and paths

...with respect to the use of forward slashes in windows -- M$ sees the two as equivalent...
To be more precise, the Windows API treats forward slashes and back slashes equivalently in file path arguments to all Windows API functions. However, Windows commands typically use forward slash for command line argument options.

So, while using forward slashes in file paths is fine when calling Win32 API functions (as the perl C sources do when built for Windows), using them in command line arguments when running Windows commands can be problematic.

In my Perl programs on Windows, I use forward slashes in all file paths, which works fine when calling all Perl internal functions. In the rare cases where I need to pass a file path to an external Windows command, I translate it like so: $filepath =~ tr{/}{\\};

See also: forward vs back slash python question.

Update: Note that all Win32 API functions have always treated forward slashes and back slashes equivalently in file path arguments. See also Re^2: What is the meaning of this line in Perl on linux? and Re^4: Changing filename extensions.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-24 09:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found