in reply to in Perl find call looking to exclude folder and ignore duplicate finds.

See File::Find on $File::Find::prune. I think in your situation, you want to do something like:

... if( $File::Find::name eq '/data/logs/master' ) { $File::Find::prune = 1; # stop searching through this } elsif( -f $File::Find::name && $File::Find::name =~ /auth.log$/ +) { save_file($File::Find::name) } else { # ignore the file } ...

Replies are listed 'Best First'.
Re^2: in Perl find call looking to exclude folder and ignore duplicate finds.
by ss_ham (Initiate) on Apr 19, 2023 at 10:10 UTC
    so this how it looks ?
    my $processed_files = 0; find({ wanted => sub { if( $File::Find::name eq '/data/logs/master' ) { $File::Find::prune = 1; # stop searching through this } elsif( -f $File::Find::name && $File::Find::name =~ /auth.l +og$/ ) { save_file($File::Find::name) } else { # ignore the file } follow => 1 }, @ARGV );
      use Cwd qw( abs_path ); my %seen; my $processed_files = 0; find ({ wanted => sub { $File::Find::dir =~ m{^/data/logs/master\b} and return; -f && m/auth\.log$/ or return; $seen{abs_path ($_)}++ and return; save_file ($File::Find::name); $processed_files++; }, follow => 1, }, @ARGV);

      Enjoy, Have FUN! H.Merijn

      I don't know. Does it work for you?