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.
So... am I doing something wrong, or is there a better way of doing it? Or is File::Find just not OO friendly?sub wanted { my @file_info; push @file_info, $File::Find::name; push @file_info, $File::Find::dir; push @file_info, $_; $borg->found(@file_info); }
In reply to File::Find incompatible with OO perl? by vaevictus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |