Currently the best way for lightweight scanning very big directory tree, is using library
File::Find::Object::Rule
Using this version, you can make secure iterator object, that do not load all scanned tree into memory before it start to work.
Example use is very simple as iterator mode:
$rule=File::Find::Object::Rule->new();
$rule->Some_filter_method_read_library_examples(parameters)->eventuall
+y_next_filter();
$rule->start(path_or_array_of_paths); #here will be initialized iterat
+or. don't panic, it will not load all big directory structure
while (){
my $item=$rule->match(); #read one single item. I prefer do it here,
+ it prevents matching name as while loop break
last unless defined $item; #stop looping after last element
#here do anything with $item, it is path, example:
printf "Fetched [%s]\n",$item;
if (-l $item) {print "it is symbolic link\n"};
};
you can leave this loop in any state, and for example start next scanning by calling next $rule->start(@new_searches). It will be reinitialized, for me it works. Of course, in that situation you'' use identical filters as previous. If you want do with different filters, call .....->new() and $rule->some_filters() again.
warning, this is fork from library File::Find::Rule and File::Find, currently unmaintained for a long time. this notice I found on metacpan.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|