Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Fastest way to recurse through VERY LARGE directory tree

by Anonymous Monk
on Feb 08, 2018 at 09:00 UTC ( [id://1208690]=note: print w/replies, xml ) Need Help??


in reply to Re: Fastest way to recurse through VERY LARGE directory tree
in thread Fastest way to recurse through VERY LARGE directory tree

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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found