title: CPAN Perl modules installer not finding tar file
body: <p>It seems I have a configuration problem when installing Perl modules through CPAN and I don't know how to correct it:</p>
  
  <pre><code>[root@ip JESSE]# pwd
  /root/.cpan/sources/authors/id/J/JE/JESSE
  
  [root@ip JESSE]# ls -l
  total 240
  -rw-r--r-- 1 root root 105464 Feb 20 11:39 CHECKSUMS
  -rw-r--r-- 1 root root   9223 Apr 12  2011 Locale-Maketext-Simple-0.21.tar.gz
  -rw-r--r-- 1 root root 125483 Feb 20 11:39 WWW-Mechanize-1.72.tar.gz
  
  [root@ip JESSE]# cpan -i WWW::Mechanize
  CPAN: Storable loaded ok (v2.20)
  Reading '/root/.cpan/Metadata'
    Database was generated on Mon, 20 Feb 2012 11:10:26 GMT
  Running install for module 'WWW::Mechanize'
  Running make for J/JE/JESSE/WWW-Mechanize-1.72.tar.gz
  CPAN: Digest::SHA loaded ok (v5.61)
  CPAN: Compress::Zlib loaded ok (v2.033)
  Checksum for /root/.cpan/sources/authors/id/J/JE/JESSE/WWW-Mechanize-1.72.tar.gz ok
  CPAN: Archive::Tar loaded ok (v1.82)
  Uncompressed /root/.cpan/sources/authors/id/J/JE/JESSE/WWW-Mechanize-1.72.tar.gz successfully
  Using Tar:/bin/tar xvf "WWW-Mechanize-1.72.tar":
  Couldn't untar WWW-Mechanize-1.72.tar
  CPAN: File::Temp loaded ok (v0.22)
  CPAN: CPAN::Meta loaded ok (v2.112150)
  Package seems to come without Makefile.PL.
    (The test -f "/root/.cpan/build/JESSE-n72IRU/Makefile.PL" returned false.)
    Writing one on our own (setting NAME to WWWMechanize)
    Had problems unarchiving. Please build manually
  Running make test
    Make had some problems, won't test
  Running make install
    Make had some problems, won't install
  
  [root@ip JESSE]# ls -l
  total 240
  -rw-r--r-- 1 root root 105464 Feb 20 11:39 CHECKSUMS
  -rw-r--r-- 1 root root   9223 Apr 12  2011 Locale-Maketext-Simple-0.21.tar.gz
  -rw-r--r-- 1 root root 125483 Feb 20 11:39 WWW-Mechanize-1.72.tar.gz
  
  [root@ip JESSE]# which tar
  /bin/tar
  
  [root@ip JESSE]# which gzip
  /bin/gzip
  </code></pre>
  
  <p><strong>The problem seems to be here:</strong></p>
  
  <pre><code>Uncompressed /root/.cpan/sources/authors/id/J/JE/JESSE/WWW-Mechanize-1.72.tar.gz successfully
  Using Tar:/bin/tar xvf "WWW-Mechanize-1.72.tar":
  Couldn't untar WWW-Mechanize-1.72.tar
  </code></pre>
  
  <p>The tar.gz file is indeed uncompressed and can be found here in a new directory:</p>
  
  <pre><code>/root/.cpan/build/JESSE-KjCEMS/WWW-Mechanize-1.72.tar
  </code></pre>
  
  <p>If I run the same command from inside the shell, I get some more info:</p>
  
  <pre><code>cpan[1]&gt; install WWW::Mechanize
  CPAN: Storable loaded ok (v2.20)
  Reading '/root/.cpan/Metadata'
    Database was generated on Mon, 20 Feb 2012 11:10:26 GMT
  Running install for module 'WWW::Mechanize'
  Running make for J/JE/JESSE/WWW-Mechanize-1.72.tar.gz
  CPAN: Digest::SHA loaded ok (v5.61)
  CPAN: Compress::Zlib loaded ok (v2.033)
  Checksum for /root/.cpan/sources/authors/id/J/JE/JESSE/WWW-Mechanize-1.72.tar.gz ok
  Scanning cache /root/.cpan/build for sizes
  Use of uninitialized value $newdir in substitution (s///) at /usr/lib64/perl5/Cwd.pm line 502.
  Use of uninitialized value $newdir in chdir at /usr/lib64/perl5/Cwd.pm line 510.
  Use of chdir('') or chdir(undef) as chdir() is deprecated at /usr/lib64/perl5/Cwd.pm line 510.
  Use of uninitialized value $newdir in pattern match (m//) at /usr/lib64/perl5/Cwd.pm line 525.
  Use of uninitialized value $newdir in split at /usr/lib64/perl5/Cwd.pm line 531.
  ..........................................................................--DONE
  DEL(1/10): /root/.cpan/build/CPAN-1.9600-jGTV10
  DEL(2/10): /root/.cpan/build/File-Which-1.09-yoVWZC
  DEL(3/10): /root/.cpan/build/Test-Script-1.07-aJWrXb
  DEL(4/10): /root/.cpan/build/Probe-Perl-0.01-gzZ2eR
  DEL(5/10): /root/.cpan/build/IPC-Run3-0.044-AP6EMp
  DEL(6/10): /root/.cpan/build/Time-HiRes-1.9721-xxseE6
  DEL(7/10): /root/.cpan/build/CPAN-Meta-YAML-0.003-wGtH0a
  DEL(8/10): /root/.cpan/build/JSON-PP-2.27105-fvkwNa
  DEL(9/10): /root/.cpan/build/Package-Constants-0.02-7Ms_OL
  DEL(10/10): /root/.cpan/build/Module-Metadata-1.000004-tXKIBB
  CPAN: Archive::Tar loaded ok (v1.82)
  Uncompressed /root/.cpan/sources/authors/id/J/JE/JESSE/WWW-Mechanize-1.72.tar.gz successfully
  Using Tar:/bin/tar xvf "WWW-Mechanize-1.72.tar":
  Couldn't untar WWW-Mechanize-1.72.tar
  CPAN: File::Temp loaded ok (v0.22)
  CPAN: CPAN::Meta loaded ok (v2.112150)
  Package seems to come without Makefile.PL.
    (The test -f "/root/.cpan/build/JESSE-DGrTh_/Makefile.PL" returned false.)
    Writing one on our own (setting NAME to WWWMechanize)
    Had problems unarchiving. Please build manually
  Running make test
    Make had some problems, won't test
  Running make install
    Make had some problems, won't install
  Failed during this command:
   JESSE/WWW-Mechanize-1.72.tar.gz              : unwrapped NO -- untar failed
  </code></pre>
  
  <p>It seems to me that $newdir is not being updated with the dynamically generated  <code>/root/.cpan/build/JESSE-DGrTh_/</code>  or <code>/root/.cpan/build/JESSE-KjCEMS/</code> or whatever the system generates or at least that information is not getting to the tar command</p>
  
  <p>Does anyone know how I can fix the mechanism without having to resort to a manual install ?</p>