in reply to Detecting Overridden Methods

package PkgA; use List::Util qw( first ); BEGIN { our @ISA = qw( ... ); } sub foo { 'Whee!' } sub check { return first { $_->can('foo') } @ISA; }

Replies are listed 'Best First'.
Re^2: Detecting Overridden Methods
by ikegami (Patriarch) on Feb 05, 2007 at 21:49 UTC

    The code in the parent post is neither inheritable nor importable. Fix:

    use List::Util qw( first ); sub check { my ($self, $method) = @_; my $class = ref($self) || $self; my $isa = do { no strict 'refs'; \@{$class.'::ISA'} }; return first { $_->can($method) } @$isa; }
      Doesn't use List::Util qw( first ); generate an unwanted first() "method" (actually, a function) that is inherited to all children? I would have coded this as use List::Util (); and return List::Util::first { $_->can($method) } @$isa;.