geoffleach has asked for the wisdom of the Perl Monks concerning the following question:

O Monks, some insight here would be appreciated.
$CDs = '/usr/local/opt/podcasts/CDs'; sub dir_addup { my $st = stat($File::Find::name); $dir_total += $st->size; } find(\&dir_addup, $CDs); some stuff, including creating subdir and adding files therein find(\&dir_addup, $CDs); Use of uninitialized value $cwd_untainted in chdir at /usr/share/perl5 +/File/Find.pm line 282. Use of uninitialized value $cwd in concatenation (.) or string at /usr +/share/perl5/File/Find.pm line 283. Can't cd to : No such file or directory
The referenced directory remains. FWIW, here's the details under perl -d
Use of uninitialized value $cwd_untainted in chdir at /usr/share/perl5 +/File/Find.pm line 282. at /usr/share/perl5/File/Find.pm line 282. File::Find::_find_opt(HASH(0x555f6ead3b50), "/usr/local/opt/podcas +ts/CDs/Django_Reinhardt_Djangology_08") called at /usr/share/perl5/Fi +le/Find.pm line 760 File::Find::find(CODE(0x555f6ed3e838), "/usr/local/opt/podcasts/CD +s/Django_Reinhardt_Djangology_08") called at CD_rip.pl line 126 Use of uninitialized value $cwd in concatenation (.) or string at /usr +/share/perl5/File/Find.pm line 283. at /usr/share/perl5/File/Find.pm line 283. File::Find::_find_opt(HASH(0x555f6ead3b50), "/usr/local/opt/podcas +ts/CDs/Django_Reinhardt_Djangology_08") called at /usr/share/perl5/Fi +le/Find.pm line 760 File::Find::find(CODE(0x555f6ed3e838), "/usr/local/opt/podcasts/CD +s/Django_Reinhardt_Djangology_08") called at CD_rip.pl line 126 Can't cd to : No such file or directory at /usr/share/perl5/File/Find.pm line 283. File::Find::_find_opt(HASH(0x555f6ead3b50), "/usr/local/opt/podcas +ts/CDs/Django_Reinhardt_Djangology_08") called at /usr/share/perl5/Fi +le/Find.pm line 760 File::Find::find(CODE(0x555f6ed3e838), "/usr/local/opt/podcasts/CD +s/Django_Reinhardt_Djangology_08") called at CD_rip.pl line 126

Replies are listed 'Best First'.
Re: Find.pm can't
by haukex (Archbishop) on Aug 30, 2018 at 21:27 UTC
    Use of uninitialized value $cwd in concatenation (.) or string at /usr +/share/perl5/File/Find.pm line 283. Can't cd to : No such file or directory

    That's strange... in the source, I don't see $cwd getting set by anything other than Cwd's getcwd (in your case at least). Just as a test, try adding use Cwd; to your code, and right before you call find, add print "cwd: ",getcwd()||$!,"\n"; to see if there's an obvious reason getcwd is failing.

      Coding error (blush!) revealed by your suggestion. Many thanks.
Re: Find.pm can't
by h2 (Beadle) on Jan 06, 2020 at 07:48 UTC

    "This error is usually caused by running a command from a directory that no longer exist. Try changing your directory and re-run the command."

    Because this is the top search result for the error string, I thought it would be useful to note the cause that was hitting me, running the program that was running File::Find in a virtual terminal where the current location in that terminal window no longer existed.

    I banged my head against this wall for a while, never suspecting it was just my habit of forgetting to close those terminal windows after I'd changed or removed their original location. Anyway, make sure that's not the cause if you get these errors. Luckily I found the actual answer on another page, so thought it would be good to have it here too.