Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: PERL/Windows file open error

by davido (Cardinal)
on Mar 04, 2019 at 17:17 UTC ( #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
Node Status?
node history
Node Type: note [id://1230860]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2019-07-21 00:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (7 votes). Check out past polls.

    Notices?