Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: PERL/Windows file open error

by davido (Cardinal)
on Mar 04, 2019 at 17:17 UTC ( [id://1230860]=note: print w/replies, xml ) Need Help??


in reply to PERL/Windows file open error

On line 12 (right after my $fn = ...), add this line: warn "Filename: <<<$fn>>>\n";. And observe what comes between the <<< and >>> delimiters. I suspect that you do not have a file named c$template.pks. It may seem like the obvious solution is to change the single quotes to double quotes, but then the backslashes will get interpreted as escapes, and will evaporate. This is one of the joys of dealing with Windows paths that include backslashes. There are two solutions. First, you can just keep it as is but use concatenation:

my $fn = join('', 'D:\DATA\Software\MFLOW2\MOD_CL\INSTALL\MOD_CL\INSTA +LL\RDBMS\c', $template, '.pks');

Or you could use forward slashes, and let Perl sort out with Windows what the path delimiters are:

my $fn = "D:/DATA/Software/MFLOW2/MOD_CL/INSTALL/MOD_CL/INSTALL/RDBMS/ +c$template.­pks";

According to perldoc perlport in the DOS and Derivatives section:

System calls accept either / or \ as the path separator.

That means under a Windows system you can use forward slashes. This doesn't work if you're exposing the path to the command line shell, but works just fine for system calls such as open.


Dave

Log In?
Username:
Password:

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

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

    No recent polls found