File::F...cedural(3)

πŸ’… File::Find::Rule::Procedural(3) β€” like, the whole vibe

okay so bestie, you're looking at File::Find::Rule::Procedural(3) from the User Contributed Perl Documentation and honestly? it's a little gem πŸŽ€ it's the cute procedural glow-up of File::Find::Rule, no cap.


✨ NAME ✨

File::Find::Rule::Procedural β€” it's literally File::Find::Rule's procedural interface, iykyk πŸ’–


🌸 SYNOPSIS 🌸

  use File::Find::Rule;

  # find all .pm files, procedurally
  my @files = find(file => name => '*.pm', in => \@INC);

that's it. that's the whole mood. look at her go πŸ¦‹


πŸ‘‘ DESCRIPTION πŸ‘‘

so besides the regular object-oriented interface (the main character), File::Find::Rule also hands you two subroutines to play with. two! 🫢

πŸŽ€ find( @clauses ) and rule( @clauses )

both find and rule can invoke any methods that the OO version has. and yeah β€” rule is a straight-up synonym for find, they're the same thing, twins fr fr πŸ‘―β€β™€οΈ

if you wanna pass more than one value to a clause, you do it with an anonymous array, like so:

 my $finder = find( name => [ '*.mp3', '*.ogg' ] );

find and rule both return a File::Find::Rule instance… unless one of the arguments is in, in which case it returns a list of things that match the rule. plot twist ✨

 my @files = find( name => [ '*.mp3', '*.ogg' ], in => $ENV{HOME} );
⚠️ okay this part is lowkey important: in will be the last clause evaluated, so this next bit of code searches for mp3s regardless of size. yeah. the size clause? never gets a turn 😭 the processing literally stops before it.
 my @files = find( name => '*.mp3', in => $ENV{HOME}, size => '<2k' );
                                                    ^
                                                    |
                   Clause processing stopped here ----/

πŸ¦‹ inverting a rule with !

you can also invert a single rule by prefixing it with ! πŸ’… like this:

 # large files that aren't videos
 my @files = find( file    =>
                   '!name' => [ '*.avi', '*.mov' ],
                   size    => '>20M',
                   in      => $ENV{HOME} );

big files only, and absolutely no videos allowed. we stan a picky queen πŸ‘‘


🌈 AUTHOR 🌈

Richard Clamp <richardc@unixbeard.net> β€” ty for your service bestie πŸ«‘πŸ’œ


Copyright (C) 2003 Richard Clamp. All Rights Reserved.

this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself 🧚


πŸ”₯ SEE ALSO πŸ”₯

  • File::Find::Rule β€” go check out the OO one, she's iconic too πŸ‘‘

and that's the whole page, bestie! this was File::F...cedural(3) from perl v5.42.0, dated 2025-06-11 β€” mwah, go find some files πŸ’‹πŸŽ€

πŸ“¦ where this page comes from