title: relative absolute path perl
body: <p>Following directory setup:</p>
  
  <pre><code>/dira/dirb
  /dira/dirb/myprog.pl
  </code></pre>
  
  <p><code>/dira/dirb/testa/myfilesdir</code> Contains the following files</p>
  
  <pre><code>/dira/dirb/testa/myfilesdir/file1.txt
  /dira/dirb/testa/myfilesdir/file2.txt
  </code></pre>
  
  <p>Current dir:</p>
  
  <pre><code>/dir/dirb
  
  ./myprog.pl  -p testa/myfilesdir
  </code></pre>
  
  <p>Cycle through files</p>
  
  <pre><code>while (my $file_to_proc = readdir(DIR)) {
  ...
  
  $file_to_proc = file1.txt
  $file_to_proc = file2.txt
  </code></pre>
  
  <p>what I want is</p>
  
  <pre><code>$myfile = /dira/dirb/testa/myfilesdir/file1.txt
  $myfile = /dira/dirb/testa/myfilesdir/file2.txt
  </code></pre>
  
  <p>Tried a few different perl module (CWD rel2abs) but it is using current directory. I can not use current directory because input could be relative or absolute path.</p>