I'm hoping TMTOWTDI ... is File::Find just not OO friendly?

I seem to be getting repetitive on this point (can't help myself)... Yes, TMTOWTDI, and File::Find is, in a number of respects, somewhat unfriendly, period.

If you like the "pure-Perl-ness" of File::Find, and you don't mind the wierd usage or the 5x typical slowdown in execution time, then go for it -- it's good to see the other replies showing that it can co-exist with OO methods.

But have you ever used the unix "find" utility? Isn't it just easier? (It certainly runs faster.) If you know what you're looking for, and you have a starting path to look in, then you could do this:

open( FIND, "find $dir -print0 |" ) or die "can't run find: $!"; # put any other find options you need between $dir and "-print0" { local $/ = "\0" # use null byte as input record separator while (<FIND>) { chomp; my $name = my $dir = $_; if ( s{(.+)/}{} ) { $dir = $1; else { $dir = "/"; # emulate File::Find's behavior $_ = "." if ( $name eq $dir ); } $borg->( $name, $dir, $_ ); } } close FIND;
And if you're on an ms-windows box, of course, "find" has been ported to that OS (cf. Cygwin, GNU, among others). Note that the "standard" solaris version of find does not support "-print0"; you need GNU or FreeBSD find for that.

In reply to Re: File::Find incompatible with OO perl? by graff
in thread File::Find incompatible with OO perl? by vaevictus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.