vaevictus has asked for the wisdom of the Perl Monks concerning the following question:
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); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File::Find incompatible with OO perl?
by broquaint (Abbot) on Feb 09, 2004 at 16:50 UTC | |
by demerphq (Chancellor) on Feb 09, 2004 at 18:28 UTC | |
by vaevictus (Pilgrim) on Feb 09, 2004 at 17:09 UTC | |
by broquaint (Abbot) on Feb 09, 2004 at 17:26 UTC | |
|
Re: File::Find incompatible with OO perl?
by ysth (Canon) on Feb 09, 2004 at 16:48 UTC | |
by vaevictus (Pilgrim) on Feb 09, 2004 at 17:08 UTC | |
by ysth (Canon) on Feb 09, 2004 at 17:59 UTC | |
by vaevictus (Pilgrim) on Feb 10, 2004 at 05:38 UTC | |
|
Re: File::Find incompatible with OO perl?
by graff (Chancellor) on Feb 10, 2004 at 06:04 UTC |