in reply to File::Find::prune problems
I tested with:
find(\&wanted, "/usr/home/amarquis"); sub wanted { print $File::Find::name . "\n"; if ($File::Find::dir =~ /images/) { $File::Find::prune = 1; } }
And indeed it continued to call wanted for files in "images" but did not go into subdirectories. But since you already have in place a check to see if you want to prune a directory, why not extend that check to before you process a file? For example:
sub wanted { # Prune this directory so we don't recurse farther, # And return so we don't process this file. if ($File::Find::dir =~ /images/) { $File::Find::prune = 1; return; } # Now we can do our processing: print $File::Find::name . "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File::Find::prune problems
by runrig (Abbot) on Mar 28, 2008 at 16:38 UTC | |
by amarquis (Curate) on Mar 28, 2008 at 20:32 UTC | |
by Anonymous Monk on Feb 26, 2016 at 00:14 UTC | |
|
Re^2: File::Find::prune problems
by spx2 (Deacon) on Mar 28, 2008 at 13:15 UTC | |
by amarquis (Curate) on Mar 28, 2008 at 15:02 UTC | |
by runrig (Abbot) on Mar 28, 2008 at 16:46 UTC | |
by Anonymous Monk on Mar 28, 2008 at 15:01 UTC |