title: Can't opendir "No such file or directory" in Perl
body: <p>I am trying to send a file path from a text file into a varible. I then want to use that file path and open it and list the directories inside. </p>
  
  <pre><code>open (FILE, 'drive_path.txt') or die $!;
  my $dir= (&lt;FILE&gt;);
  close (FILE);
  chomp $dir;
  print $dir;
  opendir (DIR, '$dir') or die $!;
  </code></pre>
  
  <p>The print output gives me the correct path location:</p>
  
  <pre><code>C:\Documents and Settings\KSoli7151794\Desktop\TEST
  </code></pre>
  
  <p>But for some reason, it says "No such file or Directory"
  Any help?</p>
  
  <p>EDIT: Here is the list of files on my Desktop:
   Volume in drive C is Operating System Drive
   Volume Serial Number is 18C9-6274</p>
  
  <p>Directory of C:\Documents and Settings\KSoli7151794\Desktop</p>
  
  <pre><code>10/04/2013  11:35 AM    &lt;DIR&gt;          .
  10/04/2013  11:35 AM    &lt;DIR&gt;          ..
  11/18/2010  11:27 AM           587,776 7za.exe
  10/04/2013  11:31 AM                51 drive_path.txt
  10/03/2013  05:39 PM             1,494 ExtractAndCreate.bat
  09/27/2013  04:34 PM               604 ExtractAndDelete.bat
  10/04/2013  11:30 AM             1,854 ParseAndRename.pl
  08/07/2013  11:38 AM    &lt;DIR&gt;          Resources
  10/04/2013  11:06 AM    &lt;DIR&gt;          TEST
  10/04/2013  11:35 AM                 0 test.txt
                 8 File(s)        995,380 bytes
                 4 Dir(s)  285,785,993,216 bytes free
  </code></pre>
  
  <p>New Code with Error Message:</p>
  
  <pre><code>open (FILE, 'drive_path.txt') or die $!;
  my $dir= (&lt;FILE&gt;);
  close (FILE);
  chomp $dir;
  print $dir;
  opendir (DIR, $dir) or die $!;
  
  C:\Documents and Settings\KSoli7151794\Desktop\TEST
  Invalid argument at ParseandRename.pl line 18
  </code></pre>
  
  <p>First 18 lines</p>
  
  <pre><code>#!/usr/local/bin/perl
  
  use strict;
  use warnings;
  
  open (FILE, 'drive_path.txt') or die $!;
  local $/;
  my $blocksize;
  my $directory;
  my $testcase;
  my $count = -1;
  my @foldernames;
  my @testsuite;
  my $dir = (&lt;FILE&gt;);
  close (FILE);
  chomp $dir;
  print $dir;
  opendir (DIR, $dir) or die $!;
  </code></pre>
  
  <p>SOLUTION:
  I took out <code>local$/;</code> and it seems to be working as intended.</p>