title: relative file paths in perl
body: <p>I have a perl script which is using relative file paths. </p>
  
  <p>The relative paths seem to be relative to the location that the script is executed from rather than the location of the perl script. How do I make my relative paths relative to the location of the script?</p>
  
  <p>For instance I have a directory structure</p>
  
  <pre><code>dataFileToRead.txt
  -&gt;bin
    myPerlScript.pl
  -&gt;output
  </code></pre>
  
  <p>inside the perl script I open dataFileToRead.txt using the code
      my $rawDataName = "../dataFileToRead.txt";
      open INPUT, "&lt;", $rawDataName;</p>
  
  <p>If I run the perl script from the bin directory then it works fine</p>
  
  <p>If I run it from the parent directory then it can't open the data file.</p>