Or... Don't try to do everything inside of your wanted(). Just have wanted() build your array of filenames then iterate over the list, outside of find(), to do the pruning. Performance is not impacted as your runtime is totally dominated by disk access.
my @filelist;
find ( \&callback, @directories );
sub callback {
...
push @filelist, $_;
}
# Prune the list
my @somefiles = grep { some_code } @filelist;
s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s
|-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,,
$|=1,select$,,$,,$,,1e-1;print;redo}