title: Using Perl on Windows, how can I ensure I get the path in the correct case following a chdir?
body: <p>Consider the following code:</p>
  
  <pre><code>print cwd . "\n";
  $str= "../source"; # note the lower case 's'    
  chdir($str);
  print cwd . "\n";
  </code></pre>
  
  <p>If my current directory is <code>c:\parentdir\Source</code> (note the capital 'S'), the output of this will be:</p>
  
  <pre>
  c:/parentdir/Source
  c:/parentdir/source
  </pre>
  
  <p>This causes problems in a subroutine of mine that cares about the correct case of folder names. $str is passed in to my subroutine, so I can't know ahead of time whether it has the correct case. How do I determine the case-correct name of a path that matches <code>$str</code>?</p>
  
  <p>More detail here:</p>
  
  <ul>
  <li>I realize that <code>../source</code> is a pathological example, but it serves to
  illustrate the problem. It occurs even if <code>$str</code> is requesting a
  folder other than the current one.</li>
  <li>I have tried numerous options, including <code>rel2abs</code>, a glob search on
  <code>$str</code>, and others, but they all seem to return "<code>source</code>" instead of
  "<code>Source</code>".</li>
  <li>I could search <code>$str/..</code> for all directories, convert them all to
  absolute paths and compare them to an absolute path version of <code>$str</code>,
  but that seems like a hack. I was hoping for something more elegant.</li>
  </ul>