Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: passing argument to sub wanted

by starbolin (Hermit)
on May 14, 2008 at 15:39 UTC ( [id://686547]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://686547]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (None)
    As of 2024-04-25 00:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found