runrig has asked for the wisdom of the Perl Monks concerning the following question:
I know there are other ways to accomplish what I want, but what do you think would be the best way, and would you condsider the above behaviour to be a bug? For now, I'm just declaring an empty foo() function in Bar:package Foo; use strict; use warnings; sub foo { print "foo\n" } sub bar { my $class = shift; if ( my $f = $class->can("foo") ) { print "yes, I can foo\n"; $f->(); } } package Bar; use strict; use warnings; our @ISA = "Foo"; sub foo; package main; use strict; use warnings; Bar->bar(); # OUTPUT: yes, I can foo Undefined subroutine &Bar::foo called at ./test_foo line 17.
Update: moved bar() to better simulate actual code.sub foo {}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Attempt to uninherit method
by chromatic (Archbishop) on Dec 21, 2007 at 00:59 UTC | |
by runrig (Abbot) on Dec 21, 2007 at 01:39 UTC | |
by chromatic (Archbishop) on Dec 21, 2007 at 01:54 UTC | |
by runrig (Abbot) on Dec 21, 2007 at 02:27 UTC | |
|
Re: Attempt to uninherit method
by runrig (Abbot) on Dec 21, 2007 at 01:00 UTC | |
by ysth (Canon) on Dec 21, 2007 at 05:42 UTC | |
by runrig (Abbot) on Dec 21, 2007 at 05:49 UTC | |
|
Re: Attempt to uninherit method
by dragonchild (Archbishop) on Dec 22, 2007 at 15:16 UTC |