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