Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: file open with variables

by afoken (Chancellor)
on Sep 27, 2022 at 17:15 UTC ( [id://11147137]=note: print w/replies, xml ) Need Help??


in reply to Re: file open with variables
in thread file open with variables

a backslash is special in double quotes, so it needs to be backslashed to keep its literal meaning.

In this special case, a DOS-style path on Windows not passed to legacy applications, using forward slashes instead of backslashes also works and is slightly more readable:

open(DLOG, '<', "D:/PROJ/N12${X_info}_X$X_info/dataInfo_X${Y_info}_Y${ +Z_info}_decode.csv") or die "we have a problem: $!";

(Explaining the forward slashes: The entire Windows API accepts both forward slashes and backslashes, and so did DOS. Only a few legacy commands use forward slashes to introduce switch parameters. Perl does not care at all about forward slashes or backslashes in path names, it just passses the path name to the underlying operating system. See Re^2: What is the meaning of this line in Perl on linux? and the links in that subthread for more details.)

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-19 17:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found