title: Perl: Get case-sensitive name of file
body: <p>I have a Perl script that needs to work on any platform (Windows,Mac,Linux,...).  Part of its functionality is to rename files, but I don't want it to overwrite existing files.  Let's say the script is called "my_rename" and it takes the same arguments as the "rename" function, and the user executes this command:</p>
  
  <p>my_rename test.txt test.TXT</p>
  
  <p>The problem occurs if -e "test.txt" and -e "test.TXT" both return true.  Here is how I would like to handle this situation under the following conditions:</p>
  
  <p>Case 1: On a case-sensitive filesystem:</p>
  
  <ul>
  <li>abort with an error that "test.TXT" exists</li>
  </ul>
  
  <p>Case 2: On a case-insensitive filesytem when the actual case of the existing filename is "test.TXT":</p>
  
  <ul>
  <li>give a warning that the file name is unchanged</li>
  </ul>
  
  <p>Case 3: On a case-insensitive filesytem when the actual case of the existing filename is NOT "test.TXT":</p>
  
  <ul>
  <li>rename the file to "test.TXT"</li>
  </ul>
  
  <p>Since this script has to be portable, it can not rely on system dependent functions or utilities.</p>
  
  <p>Any suggestions would be appreciated.</p>
  
  <ul>
  <li>Phil</li>
  </ul>