I feel for you.
You are tasked with modifying very bad code.

Things go wrong from the very first program statement.
cwd is a "buzz word" meaning: current working directory.

Without getting into fancy stuff, I show below why the first statement is wrong ('cwd' is almost certainly not what is intended for $Kitdir). And then I say that there is no need to translate "forward slash" to "back slash". Perl will do that for you when it is necessary as a path name! I show you that this translation works, but don't do it!

$KitDir = cwd; print "$KitDir\n"; # prints 'cwd' use Cwd; $Kdir = getcwd(); # $Kdir is: Where am I? print "$Kdir\n"; # prints 'C:/TEMP' $Kdir =~ s|/|\\|g; # not necessary! Don't! print "$Kdir\n"; # prints 'C:\TEMP'
So that covers your first 2 program statements.
$ENV{'KITDIR'} = $KitDir; #assigns $KitDir value to #KITDIR key in ENV hash
In the below:
I don't think that $ENV{'KITDIR'} will wind up with what you think it will.
$KitDir = $ENV{'KITDIR'}; if ($KitDir eq "") { $KitDir = $Config::Conn{KitDir}; }
I suppose we could have:
$ENV{'KITDIR'} ||= $Config::Conn($KitDir);
but it is hard for me to see how $ENV{'KITDIR'} could be false given the above statements.

In reply to Re: variable initilization by Marshall
in thread variable initilization by mtrasp

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.