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


In reply to Re: PERL/Windows file open error by davido
in thread PERL/Windows file open error by mgabalins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.