in reply to passing argument to sub wanted

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}

Replies are listed 'Best First'.
Re^2: passing argument to sub wanted
by Jenda (Abbot) on May 21, 2008 at 02:01 UTC

    And hope the script is not run on a computer where the directories contain too many files. Besides, that code would produce something somewhat usable only if the @directories contained a single directory and that directory had no subdirectories. You only stored the filenames!

    The condition in front of the push() is insanely complex, but there is no reason whatsoever not to include the pruning within the wanted() subroutine.