File::Find::Object(3)

πŸ’– File::Find::Object(3) πŸ’–

okay so bestie, this is a User Contributed Perl Documentation page for File::Find::Object, and honestly? it ate. let's get into it 🫢


✨ NAME ✨

File::Find::Object β€” an object oriented File::Find replacement. yes, it's giving glow-up. πŸ’…


πŸŽ€ VERSION πŸŽ€

version 0.3.9 β€” iconic, current, no notes ✨


🌸 SYNOPSIS 🌸

like, here's the whole vibe in nine lines:

use File::Find::Object;
my $tree = File::Find::Object->new({}, @targets);

while (my $r = $tree->next()) {
    print $r ."\n";
}

that's it. that's the whole mood. πŸ¦‹


πŸ¦‹ DESCRIPTION πŸ¦‹

so File::Find::Object does the exact same job as File::Find, but it works like an object and with an iterator. literally the same job, better energy.

here's why the original File::Find was lowkey problematic:

  • File::Find is not object oriented, so you literally cannot run multiple searches in the same application. one search. that's the limit. πŸ’€
  • the second problem is its file processing: after starting its main loop, you can't easily wait for another event and then get the next result. it's giving "no thoughts, head empty" β€” the loop just goes.

with File::Find::Object you can get the next file by calling the next() function, but setting a callback is still possible. best of both worlds, fr fr. πŸ‘‘


⭐ FUNCTIONS ⭐

πŸ’œ new

my $ffo = File::Find::Object->new( { options }, @targets);

creates a new File::Find::Object object. @targets is the list of directories or files which the object should explore. give it places to go, bestie. πŸ—ΊοΈ

🌈 options

  • depth β€” Boolean. returns the directory content before the directory itself. chaos-first ordering, we respect it.
  • nocrossfs β€” Boolean. doesn't continue on filesystems different than the parent. staying in its lane, love that for it.
  • followlink β€” Boolean. follow symlinks when they point to a directory.
πŸ’– good news: you can safely set this option to true, because File::Find::Object does not follow the link if it detects a loop. self-aware king behavior.
  • filter β€” Function reference. should point to a function returning TRUE or FALSE. this function is called with the filename to filter, and if the function returns FALSE, the file is skipped. gatekeeping, but make it functional. πŸ™ˆ
  • callback β€” Function reference. should point to a function which would be called each time a new file is returned. the function is called with the current filename as an argument. like a little notification every time something new shows up. πŸŽ€

πŸ’œ next

returns the next file found by the File::Find::Object. it returns undef once the scan is completed. so like, undef is the "we're done here" text. 😭

πŸ’œ item

returns the current filename found by the File::Find::Object object β€” i.e: the last value returned by next(). it's the "wait what were we just talking about" of methods. πŸ’­

πŸ’œ next_obj

like next() only it returns the result as a convenient File::Find::Object::Result object. "$ff->next()" is equivalent to "$ff->next_obj()->path()". glow-up in object form. ✨

πŸ’œ item_obj

like item() only it returns the result as a convenient File::Find::Object::Result object. "$ff->item()" is equivalent to "$ff->item_obj()->path()". same energy, fancier wrapper. 🎁

πŸ’œ $ff->set_traverse_to([@children])

sets the children to traverse to from the current node. useful for pruning items to traverse β€” like uninviting people from the group chat, but for directory nodes. πŸ’…

accepts a single array reference.

example:

$ff->set_traverse_to([ grep { ! /\A\./ } @{ $ff->get_traverse_to }]);

(that regex is filtering out the dotfiles, iykyk πŸ‘€)

πŸ’œ $ff->prune()

prunes the current directory. equivalent to $ff->set_traverse_to([]). literally just yeets the whole child list. periodt. πŸ—‘οΈ

πŸ’œ [@children] = $ff->get_traverse_to()

retrieves the children that will be traversed to. returns a single array reference.

(example lives up there under set_traverse_to, bestie β€” scroll up 🫢)

πŸ’œ [@files] = $ff->get_current_node_files_list()

gets all the files that appear in the current directory. this value remains constant for every node, even after traversal or calls to set_traverse_to(), and is useful to use as the basis of the argument for set_traverse_to(). it's the reliable friend who never changes. 🧚

returns a single array reference.


πŸ’€ BUGS πŸ’€

no bugs are known, but it doesn't mean there aren't any. 😭 iconic disclaimer. we stay humble.


πŸ”₯ SEE ALSO πŸ”₯

  • there's an article about this module in the Perl Advent Calendar of 2006: <http://perladvent.pm.org/2006/2/>. vintage content, still slaps.
  • File::Find is the core module for traversing files in perl, which has several limitations.
  • File::Next, File::Find::Iterator, File::Walker and the unmaintained File::FTS are alternatives to this module. the whole squad, basically. 🌈

πŸ‘‘ LICENSE πŸ‘‘

Copyright (C) 2005, 2006 by Olivier Thauvin

this package is free software; you can redistribute it and/or modify it under the following terms:

  1. The GNU General Public License Version 2.0 β€” <http://www.opensource.org/licenses/gpl-license.php>
  2. The Artistic License Version 2.0 β€” <http://www.perlfoundation.org/legal/licenses/artistic-2_0.html>
  3. At your option β€” any later version of either or both of these licenses.

three whole options, choose your fighter πŸ’…


πŸ“ SUPPORT πŸ“

🌟 Websites

the following websites have more information about this module, and may be of help to you. as always, in addition to those websites please use your favorite search engine to discover more resources. (yes, google is allowed, bestie πŸ”)

  • MetaCPAN

a modern, open-source CPAN search engine, useful to view POD in HTML format.

<https://metacpan.org/release/File-Find-Object>

  • RT: CPAN's Bug Tracker

the RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.

<https://rt.cpan.org/Public/Dist/Display.html?Name=File-Find-Object>

  • CPANTS

the CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.

<http://cpants.cpanauthors.org/dist/File-Find-Object>

  • CPAN Testers

the CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.

<http://www.cpantesters.org/distro/F/File-Find-Object>

  • CPAN Testers Matrix

the CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.

<http://matrix.cpantesters.org/?dist=File-Find-Object>

  • CPAN Testers Dependencies

the CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.

<http://deps.cpantesters.org/?module=File::Find::Object>

🌟 Bugs / Feature Requests

please report any bugs or feature requests by email to "bug-file-find-object at rt.cpan.org", or through the web interface at <https://rt.cpan.org/Public/Bug/Report.html?Queue=File-Find-Object>. you will be automatically notified of any progress on the request by the system. so like, you'll know. you'll know. πŸ“¬

🌟 Source Code

the code is open to the world, and available for you to hack on. please feel free to browse it and play with it, or whatever. if you want to contribute patches, please send me a diff or prod me to pull from your repository :)

<https://github.com/shlomif/perl-file-find-object>

git clone git://github.com/shlomif/perl-file-find-object.git

go off, contribute, be the main character 🫢


🧚 AUTHOR 🧚

Shlomi Fish <shlomif@cpan.org>


πŸ’€ BUGS πŸ’€

(yeah, it's a second BUGS section. the page said it twice, so we say it twice. consistency is a vibe.)

please report any bugs or feature requests on the bugtracker website <https://github.com/shlomif/perl-file-find-object/issues>

when submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. receipts, bestie. always bring receipts. 🧾


this software is Copyright (c) 2000 by Olivier Thauvin and others.

this is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

and that's the whole page, diva πŸ’– this was File::Find::Object(3) from perl v5.42.0, dated 2025-07-25 β€” go traverse some files, you absolute icon πŸ‘‘βœ¨ no cap.

πŸ“¦ where this page comes from