1File::Find::Object(3) User Contributed Perl DocumentationFile::Find::Object(3)
2
3
4
6 File::Find::Object - An object oriented File::Find replacement
7
9 version 0.3.6
10
12 use File::Find::Object;
13 my $tree = File::Find::Object->new({}, @targets);
14
15 while (my $r = $tree->next()) {
16 print $r ."\n";
17 }
18
20 File::Find::Object does the same job as File::Find but works like an
21 object and with an iterator. As File::Find is not object oriented, one
22 cannot perform multiple searches in the same application. The second
23 problem of File::Find is its file processing: after starting its main
24 loop, one cannot easily wait for another event and so get the next
25 result.
26
27 With File::Find::Object you can get the next file by calling the next()
28 function, but setting a callback is still possible.
29
31 new
32 my $ffo = File::Find::Object->new( { options }, @targets);
33
34 Create a new File::Find::Object object. @targets is the list of
35 directories or files which the object should explore.
36
37 options
38
39 depth
40 Boolean - returns the directory content before the directory
41 itself.
42
43 nocrossfs
44 Boolean - doesn't continue on filesystems different than the
45 parent.
46
47 followlink
48 Boolean - follow symlinks when they point to a directory.
49
50 You can safely set this option to true as File::Find::Object does
51 not follow the link if it detects a loop.
52
53 filter
54 Function reference - should point to a function returning TRUE or
55 FALSE. This function is called with the filename to filter, if the
56 function return FALSE, the file is skipped.
57
58 callback
59 Function reference - should point to a function, which would be
60 called each time a new file is returned. The function is called
61 with the current filename as an argument.
62
63 next
64 Returns the next file found by the File::Find::Object. It returns undef
65 once the scan is completed.
66
67 item
68 Returns the current filename found by the File::Find::Object object,
69 i.e: the last value returned by next().
70
71 next_obj
72 Like next() only returns the result as a convenient
73 File::Find::Object::Result object. "$ff->next()" is equivalent to
74 "$ff->next_obj()->path()".
75
76 item_obj
77 Like item() only returns the result as a convenient
78 File::Find::Object::Result object. "$ff->item()" is equivalent to
79 "$ff->item_obj()->path()".
80
81 $ff->set_traverse_to([@children])
82 Sets the children to traverse to from the current node. Useful for
83 pruning items to traverse.
84
85 Accepts a single array reference.
86
87 Example:
88
89 $ff->set_traverse_to([ grep { ! /\A\./ } @{ $ff->get_traverse_to }]);
90
91 $ff->prune()
92 Prunes the current directory. Equivalent to $ff->set_traverse_to([]).
93
94 [@children] = $ff->get_traverse_to()
95 Retrieves the children that will be traversed to. Returns a single
96 array reference.
97
98 (Example under "set_traverse_to").
99
100 [@files] = $ff->get_current_node_files_list()
101 Gets all the files that appear in the current directory. This value
102 remains constant for every node, even after traversal or calls to
103 "set_traverse_to()" and is useful to use as the basis of the argument
104 for "set_traverse_to()".
105
106 Returns a single array reference.
107
109 No bugs are known, but it doesn't mean there aren't any.
110
112 There's an article about this module in the Perl Advent Calendar of
113 2006: <http://perladvent.pm.org/2006/2/>.
114
115 File::Find is the core module for traversing files in perl, which has
116 several limitations.
117
118 File::Next, File::Find::Iterator, File::Walker and the unmaintained
119 File::FTS are alternatives to this module.
120
122 Copyright (C) 2005, 2006 by Olivier Thauvin
123
124 This package is free software; you can redistribute it and/or modify it
125 under the following terms:
126
127 1. The GNU General Public License Version 2.0 -
128 http://www.opensource.org/licenses/gpl-license.php
129
130 2. The Artistic License Version 2.0 -
131 http://www.perlfoundation.org/legal/licenses/artistic-2_0.html
132
133 3. At your option - any later version of either or both of these
134 licenses.
135
137 Websites
138 The following websites have more information about this module, and may
139 be of help to you. As always, in addition to those websites please use
140 your favorite search engine to discover more resources.
141
142 • MetaCPAN
143
144 A modern, open-source CPAN search engine, useful to view POD in
145 HTML format.
146
147 <https://metacpan.org/release/File-Find-Object>
148
149 • RT: CPAN's Bug Tracker
150
151 The RT ( Request Tracker ) website is the default bug/issue
152 tracking system for CPAN.
153
154 <https://rt.cpan.org/Public/Dist/Display.html?Name=File-Find-Object>
155
156 • CPANTS
157
158 The CPANTS is a website that analyzes the Kwalitee ( code metrics )
159 of a distribution.
160
161 <http://cpants.cpanauthors.org/dist/File-Find-Object>
162
163 • CPAN Testers
164
165 The CPAN Testers is a network of smoke testers who run automated
166 tests on uploaded CPAN distributions.
167
168 <http://www.cpantesters.org/distro/F/File-Find-Object>
169
170 • CPAN Testers Matrix
171
172 The CPAN Testers Matrix is a website that provides a visual
173 overview of the test results for a distribution on various
174 Perls/platforms.
175
176 <http://matrix.cpantesters.org/?dist=File-Find-Object>
177
178 • CPAN Testers Dependencies
179
180 The CPAN Testers Dependencies is a website that shows a chart of
181 the test results of all dependencies for a distribution.
182
183 <http://deps.cpantesters.org/?module=File::Find::Object>
184
185 Bugs / Feature Requests
186 Please report any bugs or feature requests by email to
187 "bug-file-find-object at rt.cpan.org", or through the web interface at
188 <https://rt.cpan.org/Public/Bug/Report.html?Queue=File-Find-Object>.
189 You will be automatically notified of any progress on the request by
190 the system.
191
192 Source Code
193 The code is open to the world, and available for you to hack on. Please
194 feel free to browse it and play with it, or whatever. If you want to
195 contribute patches, please send me a diff or prod me to pull from your
196 repository :)
197
198 <https://github.com/shlomif/perl-file-find-object>
199
200 git clone git://github.com/shlomif/perl-file-find-object.git
201
203 Shlomi Fish <shlomif@cpan.org>
204
206 Please report any bugs or feature requests on the bugtracker website
207 <https://github.com/shlomif/perl-file-find-object/issues>
208
209 When submitting a bug or request, please include a test-file or a patch
210 to an existing test-file that illustrates the bug or desired feature.
211
213 This software is Copyright (c) 2000 by Olivier Thauvin and others.
214
215 This is free software, licensed under:
216
217 The Artistic License 2.0 (GPL Compatible)
218
219
220
221perl v5.36.0 2022-07-22 File::Find::Object(3)