in reply to Re: File::Find::prune problems
in thread File::Find::prune problems

You are pruning too late. You want to prune when $File::Find::name or $_ (not $File::Find::dir) matches the directory:
if ( -d and /images/ ) { $File::Find::prune = 1; return; } # Do your processing

Replies are listed 'Best First'.
Re^3: File::Find::prune problems
by amarquis (Curate) on Mar 28, 2008 at 20:32 UTC

    Thank you for the correction. I just tried it out, works great. For some reason I thought from the documentation that if you set prune to 1 while it was simply looking at a directory it would prune the parent directory.

Re^3: File::Find::prune problems
by Anonymous Monk on Feb 26, 2016 at 00:14 UTC

    This is a really important point - prune on $File::Find::name match works best. e.g.

    my $crnt_file = $File::Find::name; my $root = $::root_dir; if (scalar grep($crnt_file =~ m/^$root$_/, @::prune) != 0) { print Dumper($crnt_file); $File::Find::prune = 1; return; }

    This tip helped heaps. Thanks.