Okay ... incompatible might be a bit of an exaggeration, but it doesn't play nice. :)

What I want to simply do, is use an object method as the "wanted" function for File::Find. What I get is no access to the File::Find namespace vars, and the $_ is somehow borked with the object reference taking its place.

find($obj->found,$directory); ### in the object package: sub found { my $self=shift; my ($full_name, $file_dir, $file_name) = @_; print "--------------------------\n"; print $self."\n"; print $full_name."\n"; print $file_dir."\n"; print $file_name."\n"; print $File::Find::name."\n"; print $File::Find::dir."\n"; print "--------------------------\n"; }

This produces undefined values for all but $self which is setup properly.

I'm hoping TMTOWTDI, but the only way i've been able to use my object function was to write a separate non-OO wrapper.

sub wanted { my @file_info; push @file_info, $File::Find::name; push @file_info, $File::Find::dir; push @file_info, $_; $borg->found(@file_info); }
So... am I doing something wrong, or is there a better way of doing it? Or is File::Find just not OO friendly?

In reply to 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.