in reply to Re: Easy way to search files?
in thread Easy way to search files?

I wonder why people choose the OO interface for File::Find::Rule.

Personally, I prefer its functional interface. To demonstrate how clean it is, I'm rewriting the code you pasted from the documentation:

use File::Find::Rule qw(find); my @subdirs = find 'directory', in => $directory; my @files = find 'file', name => '*.pm', in => \@INC;
Would you choose the OO interface? Why?

Another nice syntax for exactly the same is find file => (name => '*.pm', in => \@INC).

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.

Replies are listed 'Best First'.
Re^3: Easy way to search files?
by adrianh (Chancellor) on Jan 06, 2003 at 13:28 UTC
    Would you choose the OO interface?

    Yes :-)

    Why?

    Because:

    • I find the OO style more readable.
    • Most of the code I write is OO. Using the OO API to File::Find::Rule saves me switching mental models.
    • Sometimes the intermediate objects are useful. You can use it to generate rules at runtime based on other conditions. This can be harder using the functional style.