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.5
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 • Search CPAN
150
151 The default CPAN search engine, useful to view POD in HTML format.
152
153 <http://search.cpan.org/dist/File-Find-Object>
154
155 • RT: CPAN's Bug Tracker
156
157 The RT ( Request Tracker ) website is the default bug/issue
158 tracking system for CPAN.
159
160 <https://rt.cpan.org/Public/Dist/Display.html?Name=File-Find-Object>
161
162 • CPAN Ratings
163
164 The CPAN Ratings is a website that allows community ratings and
165 reviews of Perl modules.
166
167 <http://cpanratings.perl.org/d/File-Find-Object>
168
169 • CPANTS
170
171 The CPANTS is a website that analyzes the Kwalitee ( code metrics )
172 of a distribution.
173
174 <http://cpants.cpanauthors.org/dist/File-Find-Object>
175
176 • CPAN Testers
177
178 The CPAN Testers is a network of smoke testers who run automated
179 tests on uploaded CPAN distributions.
180
181 <http://www.cpantesters.org/distro/F/File-Find-Object>
182
183 • CPAN Testers Matrix
184
185 The CPAN Testers Matrix is a website that provides a visual
186 overview of the test results for a distribution on various
187 Perls/platforms.
188
189 <http://matrix.cpantesters.org/?dist=File-Find-Object>
190
191 • CPAN Testers Dependencies
192
193 The CPAN Testers Dependencies is a website that shows a chart of
194 the test results of all dependencies for a distribution.
195
196 <http://deps.cpantesters.org/?module=File::Find::Object>
197
198 Bugs / Feature Requests
199 Please report any bugs or feature requests by email to
200 "bug-file-find-object at rt.cpan.org", or through the web interface at
201 <https://rt.cpan.org/Public/Bug/Report.html?Queue=File-Find-Object>.
202 You will be automatically notified of any progress on the request by
203 the system.
204
205 Source Code
206 The code is open to the world, and available for you to hack on. Please
207 feel free to browse it and play with it, or whatever. If you want to
208 contribute patches, please send me a diff or prod me to pull from your
209 repository :)
210
211 <https://github.com/shlomif/perl-file-find-object>
212
213 git clone git://github.com/shlomif/perl-file-find-object.git
214
216 Shlomi Fish <shlomif@cpan.org>
217
219 Please report any bugs or feature requests on the bugtracker website
220 <https://github.com/shlomif/perl-file-find-object/issues>
221
222 When submitting a bug or request, please include a test-file or a patch
223 to an existing test-file that illustrates the bug or desired feature.
224
226 This software is Copyright (c) 2000 by Olivier Thauvin and others.
227
228 This is free software, licensed under:
229
230 The Artistic License 2.0 (GPL Compatible)
231
232
233
234perl v5.32.1 2021-01-27 File::Find::Object(3)