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

Good day kind monks, I seem to be having a problem with File:Find::name. In my testing on my local system

use strict; use warnings; use File:Find; use Data::Dumper; my $base_path = "."; sub dir_listing($) { my ($path) = @_; my @results; finddepth ( sub { return (-d); push @results, $File:Find:name; }, $path ); return sort @results; } print Dumper(dir_listing($base_path));

This code gives me a nice recursive directory listing. The problem I am having is then I try to use this code on network samba share. I get nothing listed. When I remove the return -d I get a listing of the top directories but the code does not seem to be recursing down the tree.

When I use ~$ find ~/samba/Videos/Movies -type f i get a full dir listing of files from the samba share so I am pretty sure my connection is working. I have tried using find2perl on my find command and the code it produces has the same problem .

Any comments would help I need something to jog my mind in a different direction. And thanks for your time.

Replies are listed 'Best First'.
Re: File find and samba share error
by haj (Vicar) on Jul 23, 2018 at 17:43 UTC

    I've seen that behaviour for a samba share, too. A reasonable guess is to prevent File::Find from relying on the nlink counter:

    use File::Find; $File::Find::dont_use_nlink = 1;

    Apparently for network file systems File::Find fails to auto-detect whether it can rely on nlinks.

      Hi Haj,

      Thanks dont_use_nlink = 1 did the trick